有没有一种方法来禁用浏览器缓存,单页? [英] Is there a way to disable browser cache for a single page?
问题描述
对于一个小的内部网站上,我有一个动态正由不正确的Firefox缓存(包括AJAX)页面。有没有一种方法来禁用浏览器缓存的单页?
下面是我使用的设置:
- XAMPP阿帕奇下,在Windows服务器上运行
- PHP
澄清
这是我主要关心的内容是网页文字和默认选项的一些<选择>
秒。所以我不能只是添加随机数字图像的一些网址的结尾,例如
更新:
我跟着我已经得到的建议至今:
- 我要送非缓存头(见下文)
-
我包含时间戳URL参数,并重定向到一个新的网页是否在2秒后重新装入,这样的:
$时间戳= $ _GET ['戳'];
如果((时间() - $时间戳)→2){
标题(位置:/intranet/admin/manage_skus.php时间戳=?'时间());
}
现在萤火虫表明,头不指定缓存,但问题仍然存在。下面是页面的响应头:
日期星期五,2009年二十时41分43秒格林尼治标准时间9月25日
服务器的Apache / 2.2.11(Win32的)DAV / 2了mod_ssl / 2.2.11的OpenSSL / 0.9.8i mod_autoindex_color PHP / 5.2.8
的X技术,通过PHP / 5.2.8
周一到期,1998一点○○分00秒格林尼治标准时间12月20日
最后修改周五,2009年20时41分43秒格林尼治标准时间9月25日
缓存控制无缓存,必重新验证
杂无缓存
保持活动超时= 5,最大值= 100
连接保持
传输编码分块
内容类型text / html
添加当前的时间戳作为URL参数,例如
http://server.com/index.php?timestamp=125656789
For a small intranet site, I have a dynamic (includes AJAX) page that is being cached incorrectly by Firefox. Is there a way to disable browser caching for a single page?
Here's the setup I'm using:
- Apache under XAMPP, running on a Windows server
- PHP
Clarification
The content that I'm primarily concerned about is page text and the default options in some <select>
s. So I can't just add random numbers to the end of some image URLs, for example.
Update:
I followed the suggestions I've gotten so far:
- I'm sending nocache headers (see below)
I'm including a timestamp URL parameter and redirecting to a new one if the page is reloaded after 2 seconds, like this:
$timestamp = $_GET['timestamp']; if ((time()-$timestamp) > 2) { header('Location:/intranet/admin/manage_skus.php?timestamp='.time()); }
Now Firebug shows that the headers specify no cache, but the problem persists. Here are the response headers for the page:
Date Fri, 25 Sep 2009 20:41:43 GMT
Server Apache/2.2.11 (Win32) DAV/2 mod_ssl/2.2.11 OpenSSL/0.9.8i mod_autoindex_color PHP/5.2.8
X-Powered-By PHP/5.2.8
Expires Mon, 20 Dec 1998 01:00:00 GMT
Last-Modified Fri, 25 Sep 2009 20:41:43 GMT
Cache-Control no-cache, must-revalidate
Pragma no-cache
Keep-Alive timeout=5, max=100
Connection Keep-Alive
Transfer-Encoding chunked
Content-Type text/html
Add current timestamp as parameter of url, e.g.
http://server.com/index.php?timestamp=125656789
这篇关于有没有一种方法来禁用浏览器缓存,单页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!