Page Speed Optimization Libraries
1.7.30.3
|
#include "http_cache.h"
Public Member Functions | |
Callback (const RequestContextPtr &request_ctx) | |
virtual void | Done (FindResult find_result)=0 |
virtual bool | IsCacheValid (const GoogleString &key, const ResponseHeaders &headers)=0 |
virtual bool | IsFresh (const ResponseHeaders &headers) |
virtual int64 | OverrideCacheTtlMs (const GoogleString &key) |
void | ReportLatencyMs (int64 latency_ms) |
HTTPValue * | http_value () |
ResponseHeaders * | response_headers () |
const ResponseHeaders * | response_headers () const |
void | set_response_headers (ResponseHeaders *headers) |
HTTPValue * | fallback_http_value () |
const RequestContextPtr & | request_context () |
void | set_is_background (bool is_background) |
Protected Member Functions | |
virtual void | ReportLatencyMsImpl (int64 latency_ms) |
Class to handle an asynchronous cache lookup response.
HTTPValue* net_instaweb::HTTPCache::Callback::http_value | ( | ) | [inline] |
virtual bool net_instaweb::HTTPCache::Callback::IsCacheValid | ( | const GoogleString & | key, |
const ResponseHeaders & | headers | ||
) | [pure virtual] |
A method that allows client Callbacks to apply invalidation checks. We first (in http_cache.cc) check whether the entry is expired using normal http semantics, and if it is not expired, then this check is called -- thus callbacks can apply any further invalidation semantics it wants on otherwise valid entries. But there's no way for a callback to override when the HTTP semantics say the entry is expired.
See also OptionsAwareHTTPCacheCallback in rewrite_driver.h for an implementation you probably want to use.
Implemented in net_instaweb::OptionsAwareHTTPCacheCallback.
virtual bool net_instaweb::HTTPCache::Callback::IsFresh | ( | const ResponseHeaders & | headers | ) | [inline, virtual] |
A method that allows client Callbacks to check if the response in cache is fresh enough, in addition to it being valid. This is used while freshening resources to check that the response in cache is not only valid, but is also not going to expire anytime soon. Note that if the response in cache is valid but not fresh, the HTTPCache calls Callback::Done with find_result = kNotFound and fills in fallback_http_value() with the cached response.
virtual int64 net_instaweb::HTTPCache::Callback::OverrideCacheTtlMs | ( | const GoogleString & | key | ) | [inline, virtual] |
Overrides the cache ttl of the cached response with the given value. Note that this has no effect if the returned value is negative or less than the cache ttl of the stored value.
Reimplemented in net_instaweb::OptionsAwareHTTPCacheCallback.
void net_instaweb::HTTPCache::Callback::ReportLatencyMs | ( | int64 | latency_ms | ) |
Called upon completion of a cache lookup trigged by HTTPCache::Find by the HTTPCache code with the latency in milliseconds. Will invoke ReportLatencyMsImpl for non-background fetches in order for system implementations, like RequestContext::TimingInfo, to record the cache latency.
virtual void net_instaweb::HTTPCache::Callback::ReportLatencyMsImpl | ( | int64 | latency_ms | ) | [protected, virtual] |
Virtual implementation for subclasses to override. Default implementation calls RequestContext::TimingInfo::SetHTTPCacheLatencyMs.