Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/90.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何防止index.php缓存?_Php_Html_Caching_Browser Cache - Fatal编程技术网

如何防止index.php缓存?

如何防止index.php缓存?,php,html,caching,browser-cache,Php,Html,Caching,Browser Cache,我有一个网站(比方说example.com)。问题是,当我更新index.php页面并加载example.com时,我没有得到更新的index.php页面,而是旧页面 而如果我加载example.com/index.php,我会得到页面的更新版本 我已尝试使用以下代码禁用缓存 header('Expires: Sun, 01 Jan 2014 00:00:00 GMT'); header('Cache-Control: no-store, no-cache, must-revalidate');

我有一个网站(比方说
example.com
)。问题是,当我更新index.php页面并加载
example.com
时,我没有得到更新的
index.php
页面,而是旧页面

而如果我加载
example.com/index.php
,我会得到页面的更新版本

我已尝试使用以下代码禁用缓存

header('Expires: Sun, 01 Jan 2014 00:00:00 GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', FALSE);
header('Pragma: no-cache');
以及:

<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />


但似乎什么都不起作用。

旧index.php文件是什么意思?您是否正在添加一些内容,而您正在获取旧内容?或者站点的
资产
未得到更新?e、 g.CSS,JS?@Alok是的。我正在添加一些内容。但是当我打开网站时,比如说abc.com,我会看到旧页面(没有更新的内容)。但是如果我使用abc.com/index.php加载站点,我会得到一个新页面(包含更新的内容)。一旦文件进入缓存,它就会从缓存加载,而不是从服务器加载,因此无论在文件发送一次并由浏览器缓存后,您是否更改服务器端的标题。转到您的
abc.com
,然后按F5刷新浏览器中的缓存。顺便说一句,我想说的是,在缓存.php文件时,至少要小心,如果要缓存,请检查是否有更改请使用example.com而不是其他网站。旧index.php文件是什么意思?您是否正在添加一些内容,而您正在获取旧内容?或者站点的
资产
未得到更新?e、 g.CSS,JS?@Alok是的。我正在添加一些内容。但是当我打开网站时,比如说abc.com,我会看到旧页面(没有更新的内容)。但是如果我使用abc.com/index.php加载站点,我会得到一个新页面(包含更新的内容)。一旦文件进入缓存,它就会从缓存加载,而不是从服务器加载,因此无论在文件发送一次并由浏览器缓存后,您是否更改服务器端的标题。转到您的
abc.com
,然后按F5刷新浏览器中的缓存。顺便说一句,我想说的是,在缓存.php文件时,至少要小心,如果要缓存,请检查是否有更改请使用example.com而不是其他网站。