Page Speed Optimization Libraries
1.13.35.1
|
#include "http_cache.h"
Public Member Functions | |
Callback (const RequestContextPtr &request_ctx) | |
Callback (const RequestContextPtr &request_ctx, RequestHeaders::Properties req_properties) | |
virtual void | Done (FindResult find_result)=0 |
virtual bool | IsCacheValid (const GoogleString &key, const ResponseHeaders &headers) |
virtual bool | IsFresh (const ResponseHeaders &headers) |
virtual int64 | OverrideCacheTtlMs (const GoogleString &key) |
void | ReportLatencyMs (int64 latency_ms) |
virtual ResponseHeaders::VaryOption | RespectVaryOnResources () const =0 |
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) |
RequestHeaders::Properties | req_properties () const |
Class to handle an asynchronous cache lookup response.
|
inlineexplicit |
The 1-arg constructor does not learn anything about the request, and thus pessimistically will assume it has cookies, invalidating any response that has vary:cookie. However it will optimistically assume there is no authorization requirement. So a request-aware call to ResponseHeaders::IsProxyCacheable (e.g. via the 2-arg Callback constructor) must be applied when needed.
|
inline |
The 2-arg constructor can be used in situations where we are confident that the cookies and authorization in the request-headers are valid.
|
inline |
|
inlinevirtual |
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.
Reimplemented in net_instaweb::OptionsAwareHTTPCacheCallback.
|
inlinevirtual |
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.
|
inlinevirtual |
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 RequestTimingInfo, to record the cache latency. Can be called multiple times for various levels of cache.
|
pure virtual |
Determines whether this Get request was made in the context where arbitrary Vary headers should be respected.
Note that Vary:Accept-Encoding is ignored at this level independent of this setting, and Vary:Cookie is always respected independent of this setting. Vary:Cookie prevents cacheing resources. For HTML, however, we can cache Vary:Cookie responses as long as there is no cookie in the request.
Implemented in net_instaweb::OptionsAwareHTTPCacheCallback.