You've already forked filebrowser
mirror of
https://github.com/filebrowser/filebrowser.git
synced 2025-11-26 14:25:26 +08:00
feat: browser cache directives
This commit is contained in:
@@ -3,6 +3,7 @@ package http
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
@@ -66,3 +67,11 @@ func stripPrefix(prefix string, h http.Handler) http.Handler {
|
||||
h.ServeHTTP(w, r2)
|
||||
})
|
||||
}
|
||||
|
||||
func checkEtag(w http.ResponseWriter, r *http.Request, fTime, fSize int64) bool {
|
||||
etag := fmt.Sprintf("%x%x", fTime, fSize)
|
||||
w.Header().Set("Cache-Control", "private")
|
||||
w.Header().Set("Etag", etag)
|
||||
|
||||
return r.Header.Get("If-None-Match") == etag
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user