feat: browser cache directives

This commit is contained in:
Ramires Viana
2021-04-19 12:49:40 +00:00
parent 603203848a
commit 190cb99a79
10 changed files with 41 additions and 11 deletions

View File

@@ -79,6 +79,11 @@ func handleImagePreview(w http.ResponseWriter, r *http.Request, imgSvc ImgServic
return errToStatus(err), err
}
isFresh := checkEtag(w, r, file.ModTime.Unix(), file.Size)
if isFresh {
return http.StatusNotModified, nil
}
cacheKey := previewCacheKey(file.Path, file.ModTime.Unix(), previewSize)
cachedFile, ok, err := fileCache.Load(r.Context(), cacheKey)
if err != nil {