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

Class: HTTP_Header_Cache

Source Location: /HTTP_Header-0.3.0/Header/Cache.php

Class Overview

HTTP
   |
   --HTTP_Header
      |
      --HTTP_Header_Cache

HTTP_Header


Author(s):

Version:

  • $Revision: 1.8 $

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 39]
HTTP_Header

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.

  • Version: $Revision: 1.8 $


[ Top ]


Method Detail

HTTP_Header_Cache (Constructor)   [line 51]

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 ]

exitIfCached   [line 172]

void exitIfCached( )

Exit If Cached
  • Access: public

[ Top ]

getCacheStart   [line 71]

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

bool isCached( [int $lastModified = 0])

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

Parameters:

int   $lastModified   —  Unix timestamp of last modification.

[ Top ]

isOlderThan   [line 109]

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 ]

setLastModified   [line 188]

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 13:51:31 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.