diff --git a/lib/cover.go b/lib/cover.go index 3300934..0ecc8bf 100644 --- a/lib/cover.go +++ b/lib/cover.go @@ -52,6 +52,7 @@ func coverHandler(h handler) { headers := h.w.Header() headers["Content-Type"] = []string{"image/jpeg"} + addCacheControlHeader(h.w, false) _, err = io.Copy(h.w, f) if err != nil { diff --git a/lib/reader.go b/lib/reader.go index 78b3a15..5c8e315 100644 --- a/lib/reader.go +++ b/lib/reader.go @@ -241,6 +241,8 @@ func openEpubFile(h handler, id string, file string) error { return err } defer html.Close() + + addCacheControlHeader(h.w, false) io.Copy(h.w, html) return nil } diff --git a/lib/trantor.go b/lib/trantor.go index 6457ae8..6e21896 100644 --- a/lib/trantor.go +++ b/lib/trantor.go @@ -93,6 +93,7 @@ func downloadHandler(h handler) { headers := h.w.Header() headers["Content-Type"] = []string{"application/epub+zip"} headers["Content-Disposition"] = []string{"attachment; filename=\"" + book.Title + ".epub\""} + addCacheControlHeader(h.w, false) io.Copy(h.w, f) } @@ -207,7 +208,6 @@ func fileServer(servePath string, prefix string) func(w http.ResponseWriter, r * } func addCacheControlHeader(w http.ResponseWriter, private bool) { - // FIXME: cache of download and cover don't depends on user login if private { w.Header().Set("Cache-Control", fmt.Sprintf("max-age=%d, private", cacheMaxAge)) } else {