Forum Moderators: coopster

Message Too Old, No Replies

cache control headers

         

guille

6:55 pm on May 1, 2007 (gmt 0)

10+ Year Member



Hi everybody... ok... i have a php index calling a php script to show a image galley. now if (ie) we go from page 1 to 2 AND we com back to 1... all the images loading again.. annoying and server load :(

I saw this... and my questio is if it is correct to solver my problem:

Using this on index.php:

Header ("Last-Modified: " . gmdate("D, d M Y H:i:s",mktime (0,0,0,1,1,2000)) . " GMT"); // Date in the past
Header ("Expires: Mon, 26 Jul 2040 05:00:00 GMT"); // In other words... never expire the image
Header ("Cache-Control: max-age=10000000, s-maxage=1000000, proxy-revalidate, must-revalidate");//Cache-Control header is ESSENTIAL for forcing Netscape to load all images!... and telling the ISP caches to do the same in this case cache for 1 million seconds.

Thanks in advance.

phparion

2:46 pm on May 4, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I would suggest you to use memCached server [danga.com...]

enigma1

10:02 pm on May 4, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



you need to check if the headers sent back to your browser include a 304 (your thumbnailer code should do that if there is some sort of clien-side cache). Also you should set a proper expiry date (by using some code to calculate it) because is likely you will replace the images sooner than 2040.