fscache
fscache copied to clipboard
Controlling headers of served cache
Is there a way currently to control which headers are sent with cached hit responses? For example, if you have a resource that's being served as JSON, once it's cached the "Content-Type: application/json" header is no longer added which can be problematic in some cases.
You can chain http.Handlers together, so you can wrap the cached Handler and set the headers in the outer wrapper.
ch := fscache.Handler(cache, myExpensiveHandler)
withHeaders := http.HandlerFunc(...) {
.... set headers like normal...
ch.ServeHttp(rw, req)
}