Date: 11/16/00
- Next message: carlos <email protected>: "[phplib] RV:RV:Sessions & NT"
- Previous message: carlos <email protected>: "[phplib] RV:Sessions & NT"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
While testing some cache-related problems by watching the actual HTTP
messages being sent (via tcpdump) I noticed that some Cache-Control
header information was missing compared to what is done by the
put_headers() function in session.inc. It looks like the header()
function in PHP3 (version 3.0.14 at least) assumes that it will be
called at most once for any given header name. For example, the
following code:
header("X-Test: foo");
header("X-Test: bar");
results in just one X-Test header actually being sent, like so
X-Test: bar
The last header() call for any given header label seems to supercede
all prior calls. Since the put_headers() function calls header()
several times with the same 'Cache-Control' label for most of the
'allowcache' modes, only the last such Cache-Control header is
actually sent. The following patch to session.inc causes it to
generate a single Cache-Control header containing all the values. The
comment at the beginning of put_headers() suggests that the multiple
Cache-Control lines were deliberately done that way, but that must be
appropriate for some other version of PHP.
-- Fred Yankowski fred <email protected> tel: +1.630.879.1312 Principal Consultant www.OntoSys.com fax: +1.630.879.1370 OntoSys, Inc 38W242 Deerpath Rd, Batavia, IL 60510, USA--
*** session.inc 2000/11/13 16:23:17 1.6 --- session.inc 2000/11/16 18:43:10 1.8 *************** *** 430,453 **** $mod_gmt = gmdate("D, d M Y H:i:s", getlastmod()) . " GMT"; header("Expires: " . $exp_gmt); header("Last-Modified: " . $mod_gmt); ! header("Cache-Control: public"); ! header("Cache-Control: max-age=" . $this->allowcache_expire * 60); break; case "private": $mod_gmt = gmdate("D, d M Y H:i:s", getlastmod()) . " GMT"; header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . $mod_gmt); ! header("Cache-Control: private"); ! header("Cache-Control: max-age=" . $this->allowcache_expire * 60); ! header("Cache-Control: pre-check=" . $this->allowcache_expire * 60); break; default: header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); ! header("Cache-Control: no-cache"); ! header("Cache-Control: post-check=0, pre-check=0"); header("Pragma: no-cache"); break; } --- 430,452 ---- $mod_gmt = gmdate("D, d M Y H:i:s", getlastmod()) . " GMT"; header("Expires: " . $exp_gmt); header("Last-Modified: " . $mod_gmt); ! header("Cache-Control: public" ! . ", max-age=" . $this->allowcache_expire * 60); break; case "private": $mod_gmt = gmdate("D, d M Y H:i:s", getlastmod()) . " GMT"; header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . $mod_gmt); ! header("Cache-Control: private" ! . ", max-age=" . $this->allowcache_expire * 60 ! . ", pre-check=" . $this->allowcache_expire * 60); break; default: header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); ! header("Cache-Control: no-cache, post-check=0, pre-check=0"); header("Pragma: no-cache"); break; }
--------------------------------------------------------------------- To unsubscribe, e-mail: phplib-unsubscribe <email protected> For additional commands, e-mail: phplib-help <email protected>
- Next message: carlos <email protected>: "[phplib] RV:RV:Sessions & NT"
- Previous message: carlos <email protected>: "[phplib] RV:Sessions & NT"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

