fix: file caching directive

This commit is contained in:
Ramires Viana 2021-08-06 12:31:39 +00:00 committed by Oleg Lobanov
parent 25c8788390
commit c63cc5a2d2
3 changed files with 11 additions and 31 deletions

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
}