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

Class: HTTP_Header2_Cache

Source Location: /HTTP_Header2-0.1.0/HTTP/Header2/Cache.php

Class Overview

HTTP2
   |
   --HTTP_Header2
      |
      --HTTP_Header2_Cache

HTTP_Header2_Cache


Author(s):

Version:

  • $Revision$

Methods


Inherited Variables

Inherited Methods

Class: HTTP_Header2

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

Class Details

[line 52]
HTTP_Header2_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_Header2_Cache(4'weeks');
  3.   $httpCache->sendHeaders();
  4.   // your code goes here



[ Top ]


Method Detail

__construct (Constructor)   [line 62]

HTTP_Header2_Cache __construct( [int $expires = 0], [string $unit = 'seconds'])

Constructor

Set the amount of time to cache.

  • Access: public

Overrides HTTP_Header2::__construct() (Constructor)

Parameters:

int   $expires   —  Amount of time for cache to last
string   $unit   —  The unit of time to keep cache

[ Top ]

exitCached   [line 216]

void exitCached( )

Exit Cached

Exit with "HTTP 304 Not Modified".

  • Access: public

[ Top ]

exitIfCached   [line 202]

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 166]

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 187]

bool isPost( )

Is Post

Check if request method is "POST".

  • Access: public

[ Top ]

setLastModified   [line 230]

void setLastModified( [int $lastModified = null])

Set Last Modified
  • Access: public

Parameters:

int   $lastModified   —  The unix timestamp of last modification.

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:48:38 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.