Sessions and cache-control

From: Date: Mon, 27 Dec 2004 21:29:01 +0000
Subject: Sessions and cache-control
Groups: php.doc 
Request: Send a blank email to phpdoc+get-969365637@lists.php.net to get a copy of this message
Hi, Both the introduction to session-handling and the session_start() page MUST point out that when you start a session, PHP automatically sends headers which inhibit caching. I only discovered this via "guvnor"'s post at http://openwebmail.mirror.luxadmin.org/manual/en/function.header.php The situation which forced me to investigate this was: * one part of my site has a very large menu (it's an on-line course). * I'm actually redesigning the site. In my new design, the menu is generated dynamically even though it only changes when I add new pages. I build an array and write the nested ULs from the array. This save me from updating next / previous links on each page, which would be very time-consuming - instead I just call my menu object's "writePreviousNextLinks" method. * I decided to put the menu in an Iframe to save users from downloading the menu every time they went to a new page. * a simple test showed that the menu was being re-loaded every time I went to a new page. Setting the menu Iframe's headers via META tags worked in Internet Explorer but not in Firefox. So now I send the following headers before the menu: * Cache-control: max-age=10800 // 3 hours. * Expires {now + max-age} * Pragma: // Empty pragma. This solved the problem. Obviously if I don't want some pages to cache I will have to over-ride the headers on these pages, but that's easy enough. Best wishes, Philip Chalmers --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.804 / Virus Database: 546 - Release Date: 30/11/04

« previous php.doc (#969365637) next »