[ Index ]
 

Code source de LifeType 1.2.4

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/class/net/http/ -> httpcache.class.php (sommaire)

(pas de description)

Poids: 208 lignes (11 kb)
Inclus ou requis:0 fois
Référencé: 1 fois
Nécessite: 0 fichiers

Définit 1 class

HttpCache:: (3 méthodes):
  httpConditional()
  _httpConditionalCallBack()
  httpConditionalRefresh()


Classe: HttpCache  - X-Ref

\ingroup Net_HTTP
Enable support for HTTP/1.x conditional requests in PHP.
Goal: Optimisation
- If the client sends a HEAD request, avoid transferring data and return the correct headers.
- If the client already has the same version in its cache, avoid transferring data again (304 Not Modified).
- Possibility to control cache for client and proxies (public or private policy, life time).
- When $feedMode is set to true, in the case of a RSS/ATOM feed,
it puts a timestamp in the global variable $clientCacheDate to allow the sending of only the articles newer than the client's cache.
- When $compression is set to true, compress the data before sending it to the client and persitent connections are allowed.
- When $session is set to true, automatically checks if $_SESSION has been modified during the last generation the document.

Interface:
- function httpConditional($UnixTimeStamp,$cacheSeconds=0,$cachePrivacy=0,$feedMode=false,$compression=false)
[Required] $UnixTimeStamp: Date of the last modification of the data to send to the client (Unix Timestamp format).
[Implied] $cacheSeconds=0: Lifetime in seconds of the document. If $cacheSeconds>0, the document will be cashed and not revalidated against the server for this delay.
[Implied] $cachePrivacy=0: 0=private, 1=normal (public), 2=forced public. When public, it allows a cashed document ($cacheSeconds>0) to be shared by several users.
[Implied] $feedMode=false: Special RSS/ATOM feeds. When true, it sets $cachePrivacy to 0 (private), does not use the modification time of the script itself, and puts the date of the client's cache (or a old date from 1980) in the global variable $clientCacheDate.
[implied] $compression=false: Enable the compression and allows persistant connections (automatic detection of the capacities of the client).
[implied] $session=false: To be turned on when sessions are used. Checks if the data contained in $_SESSION has been modified during the last generation the document.
Returns: True if the connection can be closed (e.g.: the client has already the lastest version), false if the new content has to be send to the client.

Typical use:
<?php
require_once('http-conditional.php');
//Date of the last modification of the content (Unix Timestamp format).
//Examples: query the database, or last modification of a static file.
$dateLastModification=...;
if (httpConditional($dateLastModification))
{
... //Close database connections, and other cleaning.
exit(); //No need to send anything
}
//Do not send any text to the client before this line.
... //Rest of the script, just as you would do normally.
?>

Version 1.6.1, 2005-04-03, http://alexandre.alapetite.net/doc-alex/php-http-304/

------------------------------------------------------------------
Written by Alexandre Alapetite, http://alexandre.alapetite.net/cv/

Copyright 2004-2005, Licence: Creative Commons "Attribution-ShareAlike 2.0 France" BY-SA (FR),
http://creativecommons.org/licenses/by-sa/2.0/fr/
http://alexandre.alapetite.net/divers/apropos/#by-sa
- Attribution. You must give the original author credit
- Share Alike. If you alter, transform, or build upon this work,
you may distribute the resulting work only under a license identical to this one
- The French law is authoritative
- Any of these conditions can be waived if you get permission from Alexandre Alapetite
- Please send to Alexandre Alapetite the modifications you make,
in order to improve this file for the benefit of everybody

If you want to distribute this code, please do it as a link to:
http://alexandre.alapetite.net/doc-alex/php-http-304/


Généré le : Mon Nov 26 21:04:15 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics