In PHP, by default no cache related headers are sent.
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 by default it does not say开发者_运维知识库 anything about caching, can it result in say example.com/index.php getting cached in some situations?
Yes. In general, every successful response may be cached unless there are some constrains:
Unless specifically constrained by a cache-control (section 14.9) directive, a caching system MAY always store a successful response (see section 13.8) as a cache entry, MAY return it without validation if it is fresh, and MAY return it after successful validation.
Yes, usually the browser will cache certain files by default (usually images and css) if no rules have been setup on the server-side (see browser cache).
You can set up cache-control headers to control this, or disable it completely using:
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
See example #2 in header and read the note below it.
can it result in say example.com/index.php getting cached in some situations?
It shouldn't, however there's a lot of implementations out there (particularly on mobile devices / mobile proxies) which don't behave correctly in this regard.
There's also also a lot of bad information about caching - the 'Pragma: no-cache' is meaningless when sent from a server.
To prevent caching:
header("Cache-Control: no-store, no-cache, must-revalidate");
When all else fails - check the manual
精彩评论