.

BaseCacheHeaderManager Class Reference

This cache header manager implements the basics of client side caching. More...

Inheritance diagram for BaseCacheHeaderManager:
ICacheHeaderManager PrivateLazyCacheHeaderManager PrivateRigidCacheHeaderManager PublicLazyCacheHeaderManager PublicRigidCacheHeaderManager

List of all members.

Public Member Functions

  send_headers (&$content, $expirationdate, $lastmodifieddate)
  Send cache headers.

Protected Member Functions

  check_304 ($etag)
  get_cache_control ($expirationdate, $max_age)
  Returns cache control header's content.

Detailed Description

This cache header manager implements the basics of client side caching.

Definition at line 5 of file base.cacheheader.php.


Member Function Documentation

BaseCacheHeaderManager::check_304 ( etag  )  [protected]

Definition at line 37 of file base.cacheheader.php.

00037                                             {
00038                 
00039         }
BaseCacheHeaderManager::get_cache_control ( expirationdate,
max_age  
) [protected]

Returns cache control header's content.

Parameters:
timestamp  $expirationdate
int  $max_age Expiratin date minus current timestamp, already preprocessed

Reimplemented in PrivateLazyCacheHeaderManager, PrivateRigidCacheHeaderManager, PublicLazyCacheHeaderManager, and PublicRigidCacheHeaderManager.

Definition at line 47 of file base.cacheheader.php.

00047                                                                         {
00048                 return 'no-cache,no-store';
00049         }
BaseCacheHeaderManager::send_headers ( &$  content,
expirationdate,
lastmodifieddate  
)

Send cache headers.

Parameters:
string  $content
timestamp  $expirationdate
timestamp  $lastmodifieddate

Implements ICacheHeaderManager.

Definition at line 13 of file base.cacheheader.php.

00013                                                                                         {
00014                 // POST, DELETE etc should not be cached
00015                 if (!in_array(RequestInfo::current()->method(), array('GET', 'HEAD'))) {
00016                         return;
00017                 }
00018                 
00019                 $etag = md5($content);
00020                 
00021                 // Send 304, if applicable
00022                 Common::check_if_none_match($etag);
00023                 Common::check_not_modified($lastmodifieddate); // exits if not modified
00024                 
00025                 
00026                 GyroHeaders::set('Pragma', '', true);
00027                 $max_age = $expirationdate - time();
00028                 GyroHeaders::set('Cache-Control', $this->get_cache_control($expirationdate, $max_age), true);
00029                 GyroHeaders::set('Last-Modified', $lastmodifieddate ? GyroDate::http_date($lastmodifieddate) : '', false);
00030                 GyroHeaders::set('Expires', $expirationdate ? GyroDate::http_date($expirationdate) : '', false);
00031                 GyroHeaders::set('Etag', $etag, true);                  
00032                 if (Config::has_feature(Config::TESTMODE)) {
00033                         GyroHeaders::set('X-Gyro-CacheHeader-Class', get_class($this), true);
00034                 }
00035         }

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