What I’m doing
I’m pulling an image from the database and sending it to the browser with all the proper headers – the image displays fine. I also send an ETag header, using the SHA1 of the image’s content as the tag.
The images are getting called semi regularly, so caching is a bit of an issue (won’t kill the site, but nice to have).
The Problem
$_SERVER[‘HTTP_IF_NONE_MATCH’] is not available to me. As far as I can tell, this is because of PHP’s “disobey the cache controls” life style. I can’t mess with the session cache limiter, because I don’t have access. But, even if I did have access, I wouldn’t want to touch it: 99% of the site is under WordPress.
The Environment
- PHP 4 (don’t ask)
- Apache 2.2
- WordPress
- The images live in the database (largeblog), which I can’t change.
Any guidance, tip/tricks, etc. would be helpful. I don’t have much room to change the environmental/structural stuff.
Cheers.
Have you tried reading HTTP_IF_NONE_MATCH from apache_request_headers()?
If you are running pre-4.3 php, it was called getallheaders() before.
Edit
I now see, in the page I linked, that you may also want to try to put
in the appropriate .htaccess file to force Apache to set the PHP $_SERVER[…] variables you’re unsuccessfully trying to read.