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

Source for file Header_Cache.php

Documentation is available at Header_Cache.php

  1. <?php
  2.     // +----------------------------------------------------------------------+
  3.     // | PHP version 4.0                                                      |
  4.     // +----------------------------------------------------------------------+
  5.     // | Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002, 2003 The PHP Group |
  6.     // +----------------------------------------------------------------------+
  7.     // | This source file is subject to version 2.0 of the PHP license,       |
  8.     // | that is bundled with this package in the file LICENSE, and is        |
  9.     // | available at through the world-wide-web at                           |
  10.     // | http://www.php.net/license/2_02.txt.                                 |
  11.     // | If you did not receive a copy of the PHP license and are unable to   |
  12.     // | obtain it through the world-wide-web, please send a note to          |
  13.     // | license@php.net so we can mail you a copy immediately.               |
  14.     // +----------------------------------------------------------------------+
  15.     // | Authors: Wolfram Kriesing <wk@visionp.de>                            |
  16.     // |                                                                      |
  17.     // +----------------------------------------------------------------------+//
  18.     // $Id: Header_Cache.php,v 1.1 2003/01/17 15:31:02 cain Exp $
  19.  
  20.     
  21.     //
  22.     //  this file does not work, it is only an example
  23.     //  to show how i am caching my style sheets, which are dynamically
  24.     //  created
  25.     //  $tpl is an instance of the template engine (i.e. HTML_Template_Xipe as used here)
  26.     //  the CSS-file is actually also a template, which needs to be compiled first
  27.     //
  28.  
  29.     require_once 'HTTP/Header/Cache.php';
  30.  
  31.  
  32.     // compile the template (if needed), so we can check $tpl->compiled()
  33.     // compile() does only compile if there is any change (or forceCompile is true)
  34.     $tpl->compile($layout->getContentTemplate(__FILE__));
  35.  
  36.  
  37.     $httpCache = new HTTP_Header_Cache();                                          
  38.     // we are working with a style sheet, so set the content-type
  39.     $httpCache->setHeader'Content-Type' 'text/css' );        
  40.  
  41.     // if the template had NOT been compiled before, so to say NO change was made
  42.     if!$tpl->compiled() )                                      
  43.         // then we send a 304-Not modified header here
  44.         // and EXIT the code right here!
  45.         $httpCache->exitIfCached();
  46.         
  47.         
  48.         
  49.  
  50.     // otherwise we send all the headers
  51.     // in this case we added 'Last-modified' so the UA knows
  52.     // the web-server-time that will be returned for the If-Modified-Since
  53.     $httpCache->sendHeaders();
  54.  
  55.     // here we finally include the compiled-template
  56.     // this only happens if the template really has changed and
  57.     // we need to send a new file!
  58.     include($tpl->getCompiledTemplate());
  59.  
  60. ?>

Documentation generated on Mon, 11 Mar 2019 13:51:31 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.