note 13058 deleted from ref.image by tularis
| From: | tularis@php.net | Date: | Sun, 29 Jun 2008 21:13:27 +0000 |
| Subject: | note 13058 deleted from ref.image by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-140985@lists.php.net to get a copy of this message | ||
Note Submitter: npdavis at hotmail dot com
----
I build menus using image functions. I noticed that even if you preload the images, some do not
always load. In addition the image generation puts a load on the server... the answer? Cache Control
headers. These headers will cause IE and Netscape to load all images correctly and also force the
proxys and web caches to cache them, allowing your pages to render correctly, AND save you lots of
cycles: ) These headers tell both the browser and the ISP caches/proxys to cache the images.
Here is the code:
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.
These headers may or may not be redundant... any input is welcome.
In addition, it is essential for proxys and ISP caches that your re-used images have the same url...
IE create a generic image creation script, and feed it parameters. This way your
http://yoursite/imagegen.php?text=home&h=40&w=150&fontsize=13
Home link image has the same url on all of your pages... This will make your images more
proxy/cacheserver cache AND browser cache friendly.
thx,
Neil