Skip to content

Commit

Permalink
Add cache headers to POSIX version too (#416)
Browse files Browse the repository at this point in the history
  • Loading branch information
lapo-luchini authored Dec 12, 2024
1 parent 6faae37 commit e7adf39
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion cmd/conformance/posix/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ func init() {
})
}

func addCacheHeaders(value string, fs http.Handler) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
w.Header().Add("Cache-Control", value)
fs.ServeHTTP(w, r)
}
}

func main() {
klog.InitFlags(nil)
flag.Parse()
Expand Down Expand Up @@ -84,7 +91,10 @@ func main() {
})
// Proxy all GET requests to the filesystem as a lightweight file server.
// This makes it easier to test this implementation from another machine.
http.Handle("GET /", http.FileServer(http.Dir(*storageDir)))
fs := http.FileServer(http.Dir(*storageDir))
http.Handle("GET /checkpoint", addCacheHeaders("no-cache", fs))
http.Handle("GET /tile/", addCacheHeaders("max-age=31536000, immutable", fs))
http.Handle("GET /", fs)

// TODO(mhutchinson): Change the listen flag to just a port, or fix up this address formatting
klog.Infof("Environment variables useful for accessing this log:\n"+
Expand Down

0 comments on commit e7adf39

Please sign in to comment.