Firefox PHP

file.php and HTTP 304 Not Modified

Posted by Skye N. 
file.php and HTTP 304 Not Modified
April 28, 2009 07:05AM
Hello,

From a quick look at the 5.2.10 source code, it looks like file.php never sends a 304 HTTP response code (Not Modified) to a browser request for a file, but always sends a fresh copy of the file.

It seems, to me, safe to assume that attachments are immutable, and if the HTTP request header If-Modified-Since exists, then I could just blindly return 304 instead of the file, since any cached copy will be valid. In other image.php type scripts, I've done something like:

Language: PHP
if (php_sapi_name() == ';apache2handler'; || php_sapi_name() == ';apache';) { $headers = apache_request_headers(); if (isset($headers[';If-Modified-Since';]) && !empty($headers[';If-Modified-Since';])) { header(';HTTP/1.1 304 Not Modified';); exit; } }

This would cut down on my bandwidth costs dramatically since my users like to use Phorum attachments as embedded images in their signatures, and reload pages a lot!

Thanks
Skye

___
Skye Nott
Corvus Digital
Sorry, only registered users may post in this forum.

Click here to login