Page Speed Optimization Libraries
1.3.25.1
|
#include "cache_url_async_fetcher.h"
Public Member Functions | |
CacheUrlAsyncFetcher (HTTPCache *cache, UrlAsyncFetcher *fetcher) | |
virtual bool | SupportsHttps () const |
virtual void | Fetch (const GoogleString &url, MessageHandler *message_handler, AsyncFetch *base_fetch) |
HTTPCache * | http_cache () const |
UrlAsyncFetcher * | fetcher () const |
void | set_backend_first_byte_latency_histogram (Histogram *x) |
Histogram * | backend_first_byte_latency_histogram () const |
void | set_fallback_responses_served (Variable *x) |
Variable * | fallback_responses_served () const |
void | set_num_conditional_refreshes (Variable *x) |
Variable * | num_conditional_refreshes () const |
void | set_respect_vary (bool x) |
bool | respect_vary () const |
void | set_ignore_recent_fetch_failed (bool x) |
bool | ignore_recent_fetch_failed () const |
void | set_serve_stale_if_fetch_error (bool x) |
bool | serve_stale_if_fetch_error () const |
void | set_default_cache_html (bool x) |
bool | default_cache_html () const |
Composes an asynchronous URL fetcher with an http cache, to generate an asynchronous caching URL fetcher.
This fetcher will asynchronously check the cache. If the url is found in cache and is still valid, the fetch's callback will be called right away. Otherwise (if fetcher != NULL) an async fetch will be performed in the fetcher, the result of which will be written into the cache. In case the fetch fails and there is a stale response in the cache, we serve the stale response.
If fetcher == NULL, this will only perform a cache lookup and then call the callback immediately.
virtual void net_instaweb::CacheUrlAsyncFetcher::Fetch | ( | const GoogleString & | url, |
MessageHandler * | message_handler, | ||
AsyncFetch * | fetch | ||
) | [virtual] |
Asynchronously fetch a URL, set the response headers and stream the contents to fetch and call fetch->Done() when the fetch finishes.
There is an unchecked contract that response_headers are set before the response_writer or callback are used. Caution, several implementations do not satisfy this contract (but should).
TODO(sligocki): GoogleString -> GoogleUrl or at least StringPiece.
TODO(sligocki): Include the URL in the fetch, like the request headers.
Implements net_instaweb::UrlAsyncFetcher.
virtual bool net_instaweb::CacheUrlAsyncFetcher::SupportsHttps | ( | ) | const [inline, virtual] |
Determine if the fetcher supports fetching using HTTPS. By default we assume a fetcher can.
Reimplemented from net_instaweb::UrlAsyncFetcher.