fix: file caching directive

This commit is contained in:
Ramires Viana authored and Oleg Lobanov committed 2021-08-20 14:43:06 +02:00
1 parent 25c8788390
commit c63cc5a2d2
3 files changed
+11 -31

No files matched your search

+1 -5
View File
@@ -200,11 +200,6 @@ func rawDirHandler(w http.ResponseWriter, r *http.Request, d *data, file *files.
}
func rawFileHandler(w http.ResponseWriter, r *http.Request, file *files.FileInfo) (int, error) {
isFresh := checkEtag(w, r, file.ModTime.Unix(), file.Size)
if isFresh {
return http.StatusNotModified, nil
}
fd, err := file.Fs.Open(file.Path)
if err != nil {
return http.StatusInternalServerError, err
@@ -213,6 +208,7 @@ func rawFileHandler(w http.ResponseWriter, r *http.Request, file *files.FileInfo
setContentDisposition(w, r, file)
w.Header().Set("Cache-Control", "private")
http.ServeContent(w, r, file.Name, file.ModTime, fd)
return 0, nil
}