Documentation ¶
Overview ¶
Package cacheheaders implements support HTTP headers related to caching.
Currently, the package handles Cache-Control, Age and ETag
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CacheControl ¶
type CacheControl struct { // Public controls wether the Cache-Control is declared as public or private Public bool // MaxAge indicates the value of the max-age directive, set to <0 to disable MaxAge int64 // StaleWhileRevalidate indicates the value of the stale-while-revalidate directive, set to <0 to disable StaleWhileRevalidate int64 // MustRevalidate indicates whether a must-revalidate directive must be included in Cache-Control MustRevalidate bool // Override allows override the Cache-Control settings on a per-request basis. Override func(r *http.Request, cc CacheControl) CacheControl }
CacheControl contains the configuration for the generated Cache-Control header
type Headers ¶
type Headers struct {
// contains filtered or unexported fields
}
Headers provides support for returning the cache related headers. To initialize a Headers, call New().
func New ¶
func New(cacheControl *CacheControl, configHash string) *Headers
newCacheHandler returns a new cacheHandler from a *cacheConfig representing the cache configuration for an operation and the API configuration hash (typically from Api.ApiConfigHash) If cacheControl is nil, no Cache-Control header is added to responses.
func (*Headers) CacheControl ¶
CacheControl returns the value of the configured Cache-Control header for the given http.Request (which might be nil)
func (*Headers) NotModified ¶
NotModified checks the request and response headers and if they indicate the the client already has the resource, sends an http.StatusNotModified and returns true. If the headers don't match, nothing is done and false is returned.