#include "http_cache.h"
|
| 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 |
|
bool | update_stats_on_failure () const |
|
void | set_update_stats_on_failure (bool x) |
|
Class to handle an asynchronous cache lookup response.
- Todo:
- TODO(jmarantz): consider inheriting from AsyncFetch with an implementation of Write/Flush/HeadersComplete – we'd have to make Done take true/false so this would impact callers.
net_instaweb::HTTPCache::Callback::Callback |
( |
const RequestContextPtr & |
request_ctx | ) |
|
|
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.
net_instaweb::HTTPCache::Callback::Callback |
( |
const RequestContextPtr & |
request_ctx, |
|
|
RequestHeaders::Properties |
req_properties |
|
) |
| |
|
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.
HTTPValue* net_instaweb::HTTPCache::Callback::http_value |
( |
| ) |
|
|
inline |
- Todo:
- TODO(jmarantz): specify the dataflow between http_value and response_headers.
virtual bool net_instaweb::HTTPCache::Callback::IsCacheValid |
( |
const GoogleString & |
key, |
|
|
const ResponseHeaders & |
headers |
|
) |
| |
|
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.
virtual bool net_instaweb::HTTPCache::Callback::IsFresh |
( |
const ResponseHeaders & |
headers | ) |
|
|
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.
virtual int64 net_instaweb::HTTPCache::Callback::OverrideCacheTtlMs |
( |
const GoogleString & |
key | ) |
|
|
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.
virtual void net_instaweb::HTTPCache::Callback::ReportLatencyMsImpl |
( |
int64 |
latency_ms | ) |
|
|
protectedvirtual |
Virtual implementation for subclasses to override. Default implementation calls RequestTimingInfo::SetHTTPCacheLatencyMs.
virtual ResponseHeaders::VaryOption net_instaweb::HTTPCache::Callback::RespectVaryOnResources |
( |
| ) |
const |
|
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.
bool net_instaweb::HTTPCache::Callback::update_stats_on_failure |
( |
| ) |
const |
|
inline |
Indicates whether the HTTP Cache stats be updated when the lookup fails. Normally we would, except In the case of an L1 of a write-through cache.
The documentation for this class was generated from the following file: