Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Member Functions | List of all members
net_instaweb::CachingHeaders Class Referenceabstract

#include "caching_headers.h"

Public Member Functions

 CachingHeaders (int status_code)
 All StringPieces must outlive the CachingHeaders class.
 
virtual bool Lookup (const StringPiece &key, StringPieceVector *values)=0
 Implementors supply this method to provide HTTP response header values.
 
void set_url (StringPiece x)
 To obtain correct heuristics on URLs with query-parameters, supply the URL.
 
bool IsCacheable ()
 
bool IsProxyCacheable ()
 Is the resource likely to be cached by proxies?
 
bool IsExplicitlyCacheable ()
 Is this resource explicitly marked cacheable?
 
bool GetFreshnessLifetimeMillis (int64 *out_freshness_lifetime_millis)
 
bool HasExplicitFreshnessLifetime ()
 
bool HasExplicitNoCacheDirective ()
 
bool MustRevalidate ()
 Determines whether the caching headers have a must-revalidate directive.
 
bool ProxyRevalidate ()
 Determines whether the caching headers have a proxy-revalidate directive.
 
virtual bool IsLikelyStaticResourceType () const =0
 Is the given resource type usually associated wiht static resources? More...
 
virtual bool IsCacheableResourceStatusCode () const =0
 
bool IsRedirectStatusCode () const
 
int status_code () const
 
GoogleString GenerateDisabledCacheControl ()
 

Detailed Description

Todo:
TODO(jmarantz): This class is temporarily in net_instaweb so that it can conveniently reference GoogleString etc. We will move all the files in pagespeed/... to be in namespace pagespeed in a future change.

Class to embody computing caching info for Resources. This class has two advantages over static functions in resource_util: 1) It allows computation to be run once, lazily and saved rather than multiple times and thrown away. 2) It supplies virtual methods for details of caching policy so that users (including Page Speed Automatic) can tweak parts of the policy by subclassing and overriding these methods.

Member Function Documentation

GoogleString net_instaweb::CachingHeaders::GenerateDisabledCacheControl ( )

Generates a cache-control string for disabling caching, that is strictly more conservative than the existing cache-control string.

bool net_instaweb::CachingHeaders::GetFreshnessLifetimeMillis ( int64 *  out_freshness_lifetime_millis)

Get the freshness lifetime of hte given resource, using the algorithm described in the HTTP/1.1 RFC. Returns true if the resource has an explicit freshness lifetime, false otherwise. The out parameter is only valid when this function returns true.

bool net_instaweb::CachingHeaders::HasExplicitFreshnessLifetime ( )

Does the resource have an explicit freshness lifetime? This is just a wrapper around GetFreshnessLifetimeMillis().

bool net_instaweb::CachingHeaders::HasExplicitNoCacheDirective ( )

Does the resource have an explicit HTTP header directive that indicates it's not cacheable? For instance, Cache-Control: no-cache or Pragma: no-cache.

bool net_instaweb::CachingHeaders::IsCacheable ( )

Is the resource privately cacheable, either by explicit caching headers or using common caching heuristics? If you want to know if the resource is explicitly marked as cacheable, use GetFreshnessLifetimeMillis() and test to see that the output parameter it positive.

Todo:
TODO(sligocki): Rename to IsBrowserCacheable().
virtual bool net_instaweb::CachingHeaders::IsCacheableResourceStatusCode ( ) const
pure virtual

Is the given status code known to be associated with static/cacheable resources?

virtual bool net_instaweb::CachingHeaders::IsLikelyStaticResourceType ( ) const
pure virtual

Is the given resource type usually associated wiht static resources?

Tweakable methods

These methods are virtual so that derived calsses can change the policy decisions regarding what constitutes a static resource type and/or what constitutes a cacheable resource status code.


The documentation for this class was generated from the following file: