HTTP Cache- Control

后端 未结 2 1435
孤城傲影
孤城傲影 2021-01-24 10:26

I am struggling with this - In PHP, I do this for a GET AJAX call

header(\'Cache-Control: max-age = 10000, private\');

The browser still manag

相关标签:
2条回答
  • 2021-01-24 10:57

    Am I correct that you want the browser to cache the page? If so, Cache-Control "private" is likely the culprit that is preventing the browser from caching the page. According to RFC-2616 Section 14.9.1 What is Cacheable, "private" means:

    Indicates that all or part of the response message is intended for a single user and MUST NOT be cached by a shared cache. This allows an origin server to state that the specified parts of the response are intended for only one user and are not a valid response for requests by other users. A private (non-shared) cache MAY cache the response.

    Translated to plain English, this means that caching HTTP proxies may not cache the page, but the web browser can. Note, however, that web browsers often do not cache a page if Cache-Control includes "private".

    0 讨论(0)
  • 2021-01-24 11:15

    Do you use Firebug? If yes, then go to the NET tab when your page loads & inspect what headers the browser is seeing. This will give you an idea as to what might be wrong...

    I use this -

    Cache-Control   public, max-age=60
    Content-Type    text/html; charset=utf-8
    
    0 讨论(0)
提交回复
热议问题