Caching image requests through PHP - If-Modified-Since not being sent

前端 未结 5 1268
星月不相逢
星月不相逢 2021-01-13 08:33

I am serving images through php and having some problems setting it up to respond with 304 headers to save on load time.

Most of the code below I found on php.net. I

5条回答
  •  日久生厌
    2021-01-13 09:20

    Check if sessions are being used on that page, If so, try this:

    session_cache_limiter(false);
    

    If the above worked, here's the explanation:

    Php's session mechanism sends some automatic cache-related headers in order to improve the session cookie privacy, avoiding it to be cached by intermediate proxyes:

    http://php.net/manual/en/function.session-cache-limiter.php

    These automatic headers cause the browser not to ever send the If-Modified-Since header, as they instruct it to not to perform any caching at all.

提交回复
热议问题