summaryrefslogtreecommitdiff
path: root/internal/api
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-03 09:53:46 +0300
committerPaul Buetow <paul@buetow.org>2026-05-03 09:53:46 +0300
commit0f18fcd2dd98c9261f8c8ce1be1d895184567357 (patch)
tree2e87e69938772699e18a344e4db8e97c46dbe047 /internal/api
parent92a59298ac32b4ee6e4f24e6c93307eaa152cd27 (diff)
feat: hybrid cache-busting for thumbnails and covers
- Add Cache-Control: no-cache headers to thumbnail and cover endpoints (GET /api/media/{id}/thumbnail, GET /api/sets/{id}/cover, GET /s/{token}/thumbnail) so browsers revalidate instead of serving stale cached images after regeneration. - Add frontend cache-busting via ?t=Date.now() after folder cover regeneration so the browser fetches the newly overwritten image. - Replace toolbar filters with inline search syntax (min:, max:, tag:, like:, type:, sort:, minsize:, maxsize:) for faster filtering. - Remove dedicated toolbar and advanced filter panel; consolidate all filtering into the search bar. - Expand filter state to support filesize_min/filesize_max.
Diffstat (limited to 'internal/api')
-rw-r--r--internal/api/handlers_file.go1
-rw-r--r--internal/api/handlers_media.go8
-rw-r--r--internal/api/handlers_share.go1
3 files changed, 8 insertions, 2 deletions
diff --git a/internal/api/handlers_file.go b/internal/api/handlers_file.go
index 7e04de7..d8bb14f 100644
--- a/internal/api/handlers_file.go
+++ b/internal/api/handlers_file.go
@@ -80,6 +80,7 @@ func (s *Server) handleThumbnail(w http.ResponseWriter, r *http.Request) {
if !requireService(w, s.mediaSvc) {
return
}
+ w.Header().Set("Cache-Control", "no-cache")
s.fileHandler(s.mediaSvc.GetThumbnail)(w, r)
}
diff --git a/internal/api/handlers_media.go b/internal/api/handlers_media.go
index 3863ab0..afb9685 100644
--- a/internal/api/handlers_media.go
+++ b/internal/api/handlers_media.go
@@ -53,6 +53,7 @@ func (s *Server) handleGetSetCover(w http.ResponseWriter, r *http.Request) {
writeJSON(w, http.StatusInternalServerError, map[string]string{"error": err.Error()})
return
}
+ w.Header().Set("Cache-Control", "no-cache")
http.ServeFile(w, r, fr.Path)
}
@@ -231,16 +232,19 @@ func (s *Server) handleListMedia(w http.ResponseWriter, r *http.Request) {
setIDs := q.Get("set_ids")
search := q.Get("search")
typ := q.Get("type")
+ fav := q.Get("favorites")
+ minDur := q.Get("min_duration")
+ maxDur := q.Get("max_duration")
start := time.Now()
filter := parseMediaListQuery(q)
media, err := s.mediaSvc.ListMedia(r.Context(), userIDFromContext(r), filter)
dur := time.Since(start)
if err != nil {
- fmt.Printf("[api] %s set_id=%s set_ids=%s search=%q type=%s error=%v (took %s)\n", path, setID, setIDs, search, typ, err, dur)
+ fmt.Printf("[api] %s set_id=%s set_ids=%s search=%q type=%s fav=%s min=%s max=%s error=%v (took %s)\n", path, setID, setIDs, search, typ, fav, minDur, maxDur, err, dur)
writeJSON(w, http.StatusInternalServerError, map[string]string{"error": err.Error()})
return
}
- fmt.Printf("[api] %s set_id=%s set_ids=%s search=%q type=%s returned=%d (took %s)\n", path, setID, setIDs, search, typ, len(media), dur)
+ fmt.Printf("[api] %s set_id=%s set_ids=%s search=%q type=%s fav=%s min=%s max=%s returned=%d (took %s)\n", path, setID, setIDs, search, typ, fav, minDur, maxDur, len(media), dur)
writeJSON(w, http.StatusOK, media)
}
diff --git a/internal/api/handlers_share.go b/internal/api/handlers_share.go
index 71b5934..1d8d242 100644
--- a/internal/api/handlers_share.go
+++ b/internal/api/handlers_share.go
@@ -136,6 +136,7 @@ func (s *Server) handleShareThumbnail(w http.ResponseWriter, r *http.Request) {
http.Error(w, "not found", http.StatusNotFound)
return
}
+ w.Header().Set("Cache-Control", "no-cache")
s.serveFileResult(w, r, fr, false)
}