note 61883 deleted from function.header by tularis
| From: | tularis@php.net | Date: | Fri, 20 Apr 2007 14:37:33 +0000 |
| Subject: | note 61883 deleted from function.header by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-125649@lists.php.net to get a copy of this message | ||
Note Submitter: timmerca.com
----
I store a lot of images in databases rather than files, and PHP was causing my user's web
browsers to not cache these images, which means that every time they went to my web site, they were
reloading the same images over and over again. To fix this, I have added the following headers to
my download.php script:
Header("Expires: " . date("D, j M Y H:i:s", time() + (86400 * 30)) . "
UTC");
Header("Cache-Control: Public");
Header("Pragma: Public");
This causes the user's web browsers to cache the image data (in this case for 30 days, but you
can make that whatever you want). This sped up my web sites and cut down on hits to my server
considerably. So, if you are delivering images through PHP, you should consider adding these
headers to your script too.