PHP does not obey my specific ETags

What am I doing

I remove the image from the database and send it to the browser with all the relevant headers - the image is displayed normally. I also send the ETag header using the SHA1 of the image content as a tag.

Images are obtained half regularly, so caching is a bit of a problem (it won’t kill the site, but it’s nice to have it).

Problem

$ _ SERVER ['HTTP_IF_NONE_MATCH'] is not available to me. As far as I can tell, this is because the PHP "disobeying cache" lifestyle is not supported. I cannot communicate with the session cache limiter because I do not have access. But even if I had access, I would not want to touch it: 99% of the site is under WordPress.

Wednesday

  • PHP 4 (don't ask)
  • Apache 2.2
  • Wordpress
  • Images live in a database (largeblog) which I cannot change.

Any guidance, hints / tricks, etc. would be helpful. I have few opportunities to change environmental / structural material.

Greetings.

+3
source share
2 answers

Have you tried reading HTTP_IF_NONE_MATCH from apache_request_headers () ?

If you are using pre-4.3 php, it used to be called getallheaders ().


Edit Now I see on the page I'm linked to that you can also try to put

RewriteEngine on
RewriteRule .* - [E=HTTP_IF_MODIFIED_SINCE:%{HTTP:If-Modified-Since}]
RewriteRule .* - [E=HTTP_IF_NONE_MATCH:%{HTTP:If-None-Match}]

in the corresponding .htaccess file to force Apache to set the PHP variables $ _SERVER [...] that you are trying to read unsuccessfully.

+2

PHP If-None-Match, . , "PHP", "; PHP " ", , , , , , .

, , . , PHP, , Apache. PHP, Apache, - mod-rewrite, , ( !):

RewriteCond %{HTTP_IF_NONE_MATCH} (.+)
RewriteRule ^/get_image.php /get_image.php?if-none-match=%1 [B,QSA]
0

Source: https://habr.com/ru/post/1744861/


All Articles