HTTP_Header
[ class tree: HTTP_Header ] [ index: HTTP_Header ] [ all elements ]

Class: HTTP_Header_Cache

Source Location: /HTTP_Header-1.2.1/HTTP/Header/Cache.php

Class Overview

HTTP
   |
   --HTTP_Header
      |
      --HTTP_Header_Cache

HTTP_Header_Cache


Author(s):

Version:

  • $Revision: 304418 $

Methods


Inherited Variables

Inherited Methods

Class: HTTP_Header

HTTP_Header::HTTP_Header()
Constructor
HTTP_Header::dateToTimestamp()
Date to Timestamp
HTTP_Header::getHeader()
Get Header
HTTP_Header::getHttpVersion()
Get HTTP version
HTTP_Header::getStatusText()
Return Status Code Message
HTTP_Header::getStatusType()
Return HTTP Status Code Type
HTTP_Header::isClientError()
Checks if HTTP Status code is a Client Error (4xx)
HTTP_Header::isError()
Checks if HTTP Status code is Server OR Client Error (4xx or 5xx)
HTTP_Header::isInformational()
Checks if HTTP Status code is Information (1xx)
HTTP_Header::isRedirect()
Checks if HTTP Status code is a Redirect (3xx)
HTTP_Header::isServerError()
Checks if HTTP Status code is Server Error (5xx)
HTTP_Header::isSuccessful()
Checks if HTTP Status code is Successful (2xx)
HTTP_Header::redirect()
Redirect
HTTP_Header::sendHeaders()
Send Headers
HTTP_Header::sendStatusCode()
Send Satus Code
HTTP_Header::setHeader()
Set Header
HTTP_Header::setHttpVersion()
Set HTTP version

Class Details

[line 49]
HTTP_Header_Cache

This package provides methods to easier handle caching of HTTP pages. That means that the pages can be cached at the client (user agent or browser) and your application only needs to send "hey client you already have the pages".

Which is done by sending the HTTP-Status "304 Not Modified", so that your application load and the network traffic can be reduced, since you only need to send the complete page once. This is really an advantage e.g. for generated style sheets, or simply pages that do only change rarely.

Usage:

  1.   require_once 'HTTP/Header/Cache.php';
  2.   $httpCache = new HTTP_Header_Cache(4'weeks');
  3.   $httpCache->sendHeaders();
  4.   // your code goes here

  • Version: $Revision: 304418 $
  • Access: public


[ Top ]


Method Detail

HTTP_Header_Cache (Constructor)   [line 61]

object HTTP_Header_Cache HTTP_Header_Cache( [int $expires = 0], [string $unit = 'seconds'])

Constructor

Set the amount of time to cache.

  • Access: public

Parameters:

int   $expires     
string   $unit     

[ Top ]

exitCached   [line 219]

void exitCached( )

Exit Cached

Exit with "HTTP 304 Not Modified".

  • Access: public

[ Top ]

exitIfCached   [line 204]

void exitIfCached( [int $lastModified = 0])

Exit If Cached

Exit with "HTTP 304 Not Modified" if we consider to be cached.

  • Access: public

Parameters:

int   $lastModified     Unix timestamp of last modification.

[ Top ]

getCacheStart   [line 85]

int getCacheStart( )

Get Cache Start

Returns the unix timestamp of the If-Modified-Since HTTP header or the current time if the header was not sent by the client.

  • Return: unix timestamp
  • Access: public

[ Top ]

isCached   [line 167]

bool isCached( [int $lastModified = 0])

Is Cached

Check whether we can consider to be cached on the client side.

  • Return: Whether the page/resource is considered to be cached.
  • Access: public

Parameters:

int   $lastModified     Unix timestamp of last modification.

[ Top ]

isOlderThan   [line 124]

bool isOlderThan( [int $time = 0], [string $unit = 'seconds'])

Is Older Than

You can call it like this:

  1.   $httpCache->isOlderThan(1'day');
  2.   $httpCache->isOlderThan(47'days');
  3.  
  4.   $httpCache->isOlderThan(1'week');
  5.   $httpCache->isOlderThan(3'weeks');
  6.  
  7.   $httpCache->isOlderThan(1'hour');
  8.   $httpCache->isOlderThan(5'hours');
  9.  
  10.   $httpCache->isOlderThan(1'minute');
  11.   $httpCache->isOlderThan(15'minutes');
  12.  
  13.   $httpCache->isOlderThan(1'second');
  14.   $httpCache->isOlderThan(15);

If you specify something greater than "weeks" as time untit, it just works approximatly, because a month is taken to consist of 4.3 weeks.

  • Return: Returns true if requested page is older than specified.
  • Access: public

Parameters:

int   $time     The amount of time.
string   $unit     The unit of the time amount - (year[s], month[s], week[s], day[s], hour[s], minute[s], second[s]).

[ Top ]

isPost   [line 189]

bool isPost( )

Is Post

Check if request method is "POST".

  • Access: public

[ Top ]

setLastModified   [line 233]

void setLastModified( [int $lastModified = null])

Set Last Modified
  • Access: public

Parameters:

int   $lastModified     The unix timestamp of last modification.

[ Top ]


Documentation generated on Fri, 15 Oct 2010 14:30:05 +0000 by phpDocumentor 1.4.3. PEAR Logo Copyright © PHP Group 2004.