net_instaweb::HTTPCache Class Reference

#include "http_cache.h"

Inheritance diagram for net_instaweb::HTTPCache:
net_instaweb::WriteThroughHTTPCache

List of all members.

Classes

class  Callback

Public Types

enum  FindResult { kFound, kNotFound, kRecentFetchFailed, kRecentFetchNotCacheable }
 

When a lookup is done in the HTTP Cache, it returns one of these values.

More...

Public Member Functions

 HTTPCache (CacheInterface *cache, Timer *timer, Hasher *hasher, Statistics *stats)
 Does not take ownership of any inputs.
virtual void SetIgnoreFailurePuts ()
 Makes the cache ignore put requests that do not record successes.
virtual void Find (const GoogleString &key, MessageHandler *handler, Callback *callback)
virtual void Put (const GoogleString &key, HTTPValue *value, MessageHandler *handler)
virtual void Put (const GoogleString &key, ResponseHeaders *headers, const StringPiece &content, MessageHandler *handler)
virtual void Delete (const GoogleString &key)
 Deletes an element in the cache.
virtual void set_force_caching (bool force)
bool force_caching () const
Timertimer () const
virtual void RememberNotCacheable (const GoogleString &key, MessageHandler *handler)
virtual void RememberFetchFailed (const GoogleString &key, MessageHandler *handler)
bool IsCacheableContentLength (ResponseHeaders *headers) const
bool IsCacheableBodySize (int64 body_size) const
bool IsAlreadyExpired (const ResponseHeaders &headers)
Variablecache_time_us ()
Variablecache_hits ()
Variablecache_misses ()
Variablecache_expirations ()
Variablecache_inserts ()
Variablecache_deletes ()
int64 remember_not_cacheable_ttl_seconds ()
virtual void set_remember_not_cacheable_ttl_seconds (int64 value)
int64 remember_fetch_failed_ttl_seconds ()
virtual void set_remember_fetch_failed_ttl_seconds (int64 value)
int max_cacheable_response_content_length ()
virtual void set_max_cacheable_response_content_length (int64 value)
virtual const char * Name () const

Static Public Member Functions

static void Initialize (Statistics *statistics)
 Initialize statistics variables for the cache.

Static Public Attributes

static const char kCacheTimeUs []
 Names of statistics variables: exported for tests.
static const char kCacheHits []
static const char kCacheMisses []
static const char kCacheExpirations []
static const char kCacheInserts []
static const char kCacheDeletes []
static const char kEtagPrefix []
 The prefix to be added to Etags.

Protected Member Functions

virtual void PutInternal (const GoogleString &key, int64 start_us, HTTPValue *value)

Friends

class HTTPCacheCallback
class WriteThroughHTTPCache

Detailed Description

Implements HTTP caching semantics, including cache expiration and retention of the originally served cache headers.


Member Enumeration Documentation

When a lookup is done in the HTTP Cache, it returns one of these values.

Enumerator:
kRecentFetchFailed 

Helps avoid frequent refetching of resources which have error status codes or are not cacheable.


Member Function Documentation

virtual void net_instaweb::HTTPCache::Find ( const GoogleString key,
MessageHandler handler,
Callback callback 
) [virtual]

Non-blocking Find. Calls callback when done. 'handler' must all stay valid until callback->Done() is called.

Reimplemented in net_instaweb::WriteThroughHTTPCache.

bool net_instaweb::HTTPCache::IsAlreadyExpired ( const ResponseHeaders headers  ) 

Returns true if the resource is already at the point of expiration, and would never be used if inserted into the cache. Otherwise, returns false and increments the cache expirations statistic

bool net_instaweb::HTTPCache::IsCacheableBodySize ( int64  body_size  )  const

Indicates if the response body is within the cacheable size limit. If the response headers do not have content length header, then the clients of HTTPCache must check if the received response body is of cacheable size before buffering them in memory.

bool net_instaweb::HTTPCache::IsCacheableContentLength ( ResponseHeaders headers  )  const

Indicates if the response is within the cacheable size limit. Clients of HTTPCache must check if they will be eventually able to cache their entries before buffering them in memory. If the content length header is not found then consider it as cacheable. This could be a chunked response.

virtual void net_instaweb::HTTPCache::Put ( const GoogleString key,
ResponseHeaders headers,
const StringPiece &  content,
MessageHandler handler 
) [virtual]

Note that Put takes a non-const pointer for ResponseHeaders* so it can update the caching fields prior to storing.

virtual void net_instaweb::HTTPCache::Put ( const GoogleString key,
HTTPValue value,
MessageHandler handler 
) [virtual]

Note that Put takes a non-const pointer for HTTPValue so it can bump the reference count.

virtual void net_instaweb::HTTPCache::RememberFetchFailed ( const GoogleString key,
MessageHandler handler 
) [virtual]

Tell the HTTP Cache to remember that a particular key is not cacheable because the associated URL failing Fetch.

The not-cacheable setting will be 'remembered' for remember_fetch_failed_ttl_seconds_.

Reimplemented in net_instaweb::WriteThroughHTTPCache.

virtual void net_instaweb::HTTPCache::RememberNotCacheable ( const GoogleString key,
MessageHandler handler 
) [virtual]

Tell the HTTP Cache to remember that a particular key is not cacheable because the URL was marked with Cache-Control 'nocache' or Cache-Control 'private'. We would like to avoid DOSing the origin server or spinning our own wheels trying to re-fetch this resource.

The not-cacheable setting will be 'remembered' for remember_not_cacheable_ttl_seconds_.

Reimplemented in net_instaweb::WriteThroughHTTPCache.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Tue May 29 16:33:53 2012 for Page Speed Optimization Libraries by  doxygen 1.6.3