PHP Header Caching

In PHP, cache headers are not sent by default.

HTTP/1.1 200 OK
Date: Fri, 19 Nov 2010 11:02:16 GMT
Server: Apache/2.2.15 (Win32) PHP/5.2.9-2
X-Powered-By: PHP/5.2.9-2
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 26
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html

Now, since it says nothing about caching by default, can this lead to example.com/index.php being cached in some situations?

+3
source share
3 answers

Yes. In the general case, each successful response can be cached if there are no restrictions:

( 14.9), (. 13.8) , , , .

+4

, ( css), (. ).

, , , :

header("Cache-Control: no-store, no-cache, must-revalidate"); 
header("Cache-Control: post-check=0, pre-check=0", false); 
header("Pragma: no-cache");

. № 2 header .

+4

, example.com/index.php ?

, , ( / ), .

There is also a lot of bad caching information - "Pragma: no-cache" is pointless when sending from the server.

To prevent caching:

header("Cache-Control: no-store, no-cache, must-revalidate"); 

When all else fails - check the manual

+1
source

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


All Articles