note 61883 added to function.header

From: Date: Tue, 14 Feb 2006 16:07:47 +0000
Subject: note 61883 added to function.header
Groups: php.notes 
Request: Send a blank email to php-notes+get-103692@lists.php.net to get a copy of this message
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. ---- Server IP: 64.71.164.2 Probable Submitter: 69.33.133.2 ---- Manual Page -- http://www.php.net/manual/en/function.header.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+61883 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+61883&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+61883&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+61883&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+61883&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+61883&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+61883&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+61883&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+61883&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#103692) next »