Documentation ¶
Index ¶
- Variables
- func CachableStatusCode(statusCode int) bool
- func CachedResponse(c types.AbstractProviderInterface, req *http.Request, cachedKey string, ...) (*http.Response, bool, error)
- func GetVariedCacheKey(req *http.Request, headers []string) string
- func HitStaleCache(h *http.Header, ttl time.Duration)
- func IsVaryCacheable(req *http.Request) bool
- func MissCache(set func(key, value string), req *http.Request, reason string)
- func SetCacheStatusEventually(resp *http.Response) *http.Response
- func SetRequestCacheStatus(h *http.Header, header, cacheName string)
- func ValidateCacheControl(r *http.Response) bool
- func ValidateMaxAgeCachedResponse(req *http.Request, res *http.Response) *http.Response
- func ValidateMaxAgeCachedStaleResponse(req *http.Request, res *http.Response, addTime int) *http.Response
- type VaryTransport
- func (t *VaryTransport) BaseRoundTrip(req *http.Request) (string, bool, *http.Response)
- func (t *VaryTransport) GetCoalescingLayerStorage() *types.CoalescingLayerStorage
- func (t *VaryTransport) GetProvider() types.AbstractProviderInterface
- func (t *VaryTransport) GetSurrogateKeys() providers.SurrogateInterface
- func (t *VaryTransport) GetYkeyStorage() *ykeys.YKeyStorage
- func (t *VaryTransport) RoundTrip(req *http.Request) (resp *http.Response, err error)
- func (t *VaryTransport) SetCache(key string, resp *http.Response, ccValue string) bool
- func (t *VaryTransport) SetSurrogateKeys(s providers.SurrogateInterface)
- func (t *VaryTransport) SetURL(url configurationtypes.URL)
- func (t *VaryTransport) UpdateCacheEventually(req *http.Request) (*http.Response, error)
Constants ¶
This section is empty.
Variables ¶
var ErrNoDateHeader = errors.New("no Date header")
ErrNoDateHeader indicates that the HTTP headers contained no Date header.
Functions ¶
func CachableStatusCode ¶ added in v1.6.19
func CachedResponse ¶
func CachedResponse(c types.AbstractProviderInterface, req *http.Request, cachedKey string, transport types.TransportInterface) (*http.Response, bool, error)
CachedResponse returns the cached http.Response for req if present, and nil otherwise.
func GetVariedCacheKey ¶
GetVariedCacheKey returns the varied cache key for req and resp.
func HitStaleCache ¶
HitStaleCache set hit and manage age header too
func IsVaryCacheable ¶
IsVaryCacheable determines if it's cacheable
func SetCacheStatusEventually ¶
SetCacheStatusEventually eventually set cache status header
func SetRequestCacheStatus ¶
SetRequestCacheStatus set the Cache-Status fwd=request
func ValidateCacheControl ¶
ValidateCacheControl check the Cache-Control header
Types ¶
type VaryTransport ¶
VaryTransport type
func NewTransport ¶
func NewTransport(p types.AbstractProviderInterface, ykeyStorage *ykeys.YKeyStorage, surrogateStorage providers.SurrogateInterface) *VaryTransport
NewTransport returns a new Transport with the provided Cache implementation and MarkCachedResponses set to true
func (*VaryTransport) BaseRoundTrip ¶
BaseRoundTrip is the base for RoundTrip
func (*VaryTransport) GetCoalescingLayerStorage ¶
func (t *VaryTransport) GetCoalescingLayerStorage() *types.CoalescingLayerStorage
GetCoalescingLayerStorage get the coalescing layer storage
func (*VaryTransport) GetProvider ¶
func (t *VaryTransport) GetProvider() types.AbstractProviderInterface
GetProvider returns the associated provider
func (*VaryTransport) GetSurrogateKeys ¶
func (t *VaryTransport) GetSurrogateKeys() providers.SurrogateInterface
GetSurrogateKeys get the surrogate keys storage
func (*VaryTransport) GetYkeyStorage ¶
func (t *VaryTransport) GetYkeyStorage() *ykeys.YKeyStorage
GetYkeyStorage get the ykeys storage
func (*VaryTransport) RoundTrip ¶
RoundTrip takes a Request and returns a Response
If there is a fresh Response already in cache, then it will be returned without connecting to the server.
If there is a stale Response, then any validators it contains will be set on the new request to give the server a chance to respond with NotModified. If this happens, then the cached Response will be returned.
func (*VaryTransport) SetSurrogateKeys ¶
func (t *VaryTransport) SetSurrogateKeys(s providers.SurrogateInterface)
SetSurrogateKeys set the surrogate keys storage
func (*VaryTransport) SetURL ¶
func (t *VaryTransport) SetURL(url configurationtypes.URL)
SetURL set the URL
func (*VaryTransport) UpdateCacheEventually ¶
UpdateCacheEventually will handle Request and update the previous one in the cache provider