feat: browser cache directives

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

No files matched your search

+9
View File
@@ -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
}