Documentation ¶
Overview ¶
Package cache handles HTTP caching headers on responses that are cacheable.
Index ¶
Constants ¶
View Source
const ( // MinEdgeTime is the minimum amount of time a response needs to be cached to be // picked up in the Google front-end edge cache (i.e., their massively distributed one). MinEdgeTime = 61 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func Response ¶
func Response(k kami.HandlerFunc, d time.Duration) kami.HandlerFunc
Response wraps the provided kami.HandlerFunc with an HTTP cache. If the underlying handler writes http.StatusOK, Response will set headers to cache the response for the specified duration. Otherwise, Response will set headers ensuring the result is not cached.
Response understands which HTTP responses are public and which are authenticated, and it sets the Cache-Control header to public and private appropriately.
Types ¶
type CachingResponseWriter ¶
type CachingResponseWriter struct { http.ResponseWriter Duration time.Duration Public bool // contains filtered or unexported fields }
func (*CachingResponseWriter) WriteHeader ¶
func (w *CachingResponseWriter) WriteHeader(code int)
Click to show internal directories.
Click to hide internal directories.