0

When we output the $_SERVER variable like this:

die('<pre>' . print_r($_SERVER, true) . '</pre>');

We'll get alot of taha, and between them these items:

[HTTP_CONNECTION] => keep-alive
[HTTP_CACHE_CONTROL] => max-age=0

When we to page reload (Refresh button, CTRL+R or F5), they will remain there, and values will not be changed.

But when I press CTRL + F5 (clear cache), a new item will appear under those two items:

[HTTP_PRAGMA] => no-cache

So my question is what shall browser do if I set:

$_SERVER['HTTP_PRAGMA'] = 'no-cache';

On top of my PHP scripts for every request? Will the browser always understand this as—clear cache for this web page?

4

1 回答 1

1

浏览器不会做任何事情。$_SERVER不影响输出,所以浏览器看不到它。

如果要为浏览器指定缓存控制规则,请使用header()mnot 缓存指南

于 2013-03-09T09:01:18.620 回答