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

@@ -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
}