Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cache ¶
Cache stores pairs of requests/responses.
type CachedResponse ¶
type CachedResponse struct { sync.RWMutex Header http.Header Body []byte RequestTime time.Time ResponseTime time.Time Element *list.Element }
CachedResponse represents a cached HTTP response.
func NewCachedResponse ¶
NewCachedResponse constructs a new cached response.
func (*CachedResponse) Response ¶
func (e *CachedResponse) Response() *http.Response
Response converts a cached response to an HTTP response.
type CachedState ¶
type CachedState int
CachedState represents freshness of a cached response.
const ( // Miss means it's not in the cache. Miss CachedState = iota // Fresh means it has a cached response and it's available. Fresh // Stale means it has a cached response but it's not recommended. Stale // Revalidate means it has a cached response but needs confirmation from the backend. Revalidate )
type Transport ¶
type Transport struct { http.RoundTripper Cache OriginChangedAt time.Time }
Transport is a caching round tripper.
func (*Transport) RoundTrip ¶
RoundTrip returns a cached response if found. Otherwise, retrieve one from the underlying transport.
func (*Transport) State ¶
func (t *Transport) State(req *http.Request, cached *CachedResponse) (CachedState, time.Duration)
State returns the state of cached response.
type Variations ¶
type Variations struct { Fields []string VarResponse map[VarKey]*CachedResponse }
Variations represents cached responses with the same URL.
func NewVariations ¶
func NewVariations(resp *CachedResponse) *Variations
NewVariations constructs a new variations for the cached response.
Click to show internal directories.
Click to hide internal directories.