Forum Moderators: coopster

Message Too Old, No Replies

Page cache headers

         

ocon

2:18 pm on Aug 26, 2011 (gmt 0)

10+ Year Member Top Contributors Of The Month



Hello,

To track site metrics I have an "image" in the html that loads a php page using a file string unique to this user's session: /stats.php?val1=x&val2=y&user=06e6e8b4790067aa9ef664ba565bcaa9. At the browser level I want to ensure this page is cached so the browser doesn't load this image more than once.

I've looked up php page caching, but all the articles are geared towards sending headers to ensure the page is NOT cached, the opposite of what I'm looking for:

header("Expires: Tue, 1 Jan 1980 12:00:00 GMT"); // Day in past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");


I was able to rework only one header, Expires, setting that to a day in the far future. Are there any other headers I should rework or send?

header("Expires: Sat, 31 Dec 2050 12:00:00 GMT");

coopster

1:31 pm on Aug 31, 2011 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Did you check to see if your browser was requesting the page again? In other words, is it caching the page now? If so, job done. You can use tools like LiveHttpHeaders extension for Firefox or Firebug extension for Firefox for checking HTTP request and response headers.