页面上的Ajax缓存...... [英] Ajax caching on pages...
问题描述
我有一个< DIV的页面每10秒更新一次。
问题是,除非浏览器被配置为始终以
获取新页面,否则它将显示缓存中的页面。
有没有办法防止这种情况发生?
Mel在3/19/2007 11:45上说了以下内容AM:
我有一个页面,其中< DIV每10秒更新一次。
问题是,除非浏览器被配置为始终以
获取新页面,否则它将显示缓存中的页面。
有没有办法防止这种情况发生?
是的,通过在URL中添加时间戳来使用唯一的URL。
-
Randy
机会有利于准备好的心灵
comp.lang.javascript常见问题 - http://jibbering.com/faq/index.html
Javascript最佳实践 - http://www.JavascriptToolbox.com/bestpractices/
Randy Webb< Hi ************ @ aol.comwrote in
新闻:hf ***************** ***@giganews.com:
梅尔在2007年3月19日上午11:45发表以下信息:
>我有一个页面,其中< DIV每10秒更新一次。问题是,除非浏览器配置为始终在新页面上显示,否则它会从缓存中显示页面。
有没有办法防止这种情况发生?
是的,通过向URL添加时间戳来使用唯一的URL。
如果你可以到达标题,你也可以帮助它...这里是我生成的PHP代码片段的
代码页面:
// IE实际上缓存了ajax页面。只是另一个讨厌浏览器的原因。
header(" Expires:Sun,19 Nov 1978 05:00:00 GMT");
header(" Last-修改:。gmdate(" D,d MYH:i:s)。GMT);
标题(Cache-Control:no-store,no-cache, must-revalidate");
header(" Cache-Control:post-check = 0,pre-check = 0",false);
header(" Pragma:no-cache")
Good Man在2007年3月19日下午5:03发表以下内容:
Randy Webb< Hi ************ @ aol.comwrote在
新闻:hf ************* *******@giganews.com:
>梅尔在2007年3月19日上午11:45发表以下信息:
< blockquote class =post_quotes>
>>我有一个页面,其中< DIV每10秒更新一次。问题是,除非浏览器配置为始终在新页面上显示,否则它会从缓存中显示页面。
有没有办法防止这种情况发生?
是的,通过向URL添加时间戳来使用唯一的URL。
如果你可以到达标题,你也可以帮助它...这里是我的PHP生成的一段代码
代码页面:
// IE实际上缓存了ajax页面。只是讨厌浏览器的另一个原因。
讨厌浏览器,因为它不会按你想要的方式行事,而不是学习如何编码它。直觉。
header(" Expires:Sun,19 Nov 1978 05:00:00 GMT");
header("最后修改:。gmdate(" D,d MYH:i:s)。GMT);
标题(Cache-Control:no-store,no- cache,must-revalidate");
header(" Cache-Control:post-check = 0,pre-check = 0",false);
header( Pragma:no-cache)
即使设置标题,仍然无法保证。向URL添加时间戳
被证明是可靠的。
-
Randy
机会有利于准备好的思想
comp.lang.javascript常见问题 - http://jibbering.com/faq/index.html
Javascript最佳实践 - http://www.JavascriptToolbox.com/bestpractices/
I have a page with a <DIVthat gets updated every 10 seconds. The
problem is that unless the browser is configured to get new pages at
all times, it displays the page from cache.
Is there a way to prevent this from happenning ?
Mel said the following on 3/19/2007 11:45 AM:I have a page with a <DIVthat gets updated every 10 seconds. The
problem is that unless the browser is configured to get new pages at
all times, it displays the page from cache.
Is there a way to prevent this from happenning ?Yes, use a unique URL by adding a timestamp to the URL.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Randy Webb <Hi************@aol.comwrote in
news:hf********************@giganews.com:
Mel said the following on 3/19/2007 11:45 AM:>I have a page with a <DIVthat gets updated every 10 seconds. The
problem is that unless the browser is configured to get new pages at
all times, it displays the page from cache.
Is there a way to prevent this from happenning ?
Yes, use a unique URL by adding a timestamp to the URL.if you can get to the headers, you can help it too... here is a snippet of
code from my PHP generating pages:
//IE actually caches ajax pages. Just another reason to hate that browser.
header("Expires: Sun, 19 Nov 1978 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache")
Good Man said the following on 3/19/2007 5:03 PM:Randy Webb <Hi************@aol.comwrote in
news:hf********************@giganews.com:
>Mel said the following on 3/19/2007 11:45 AM:>>I have a page with a <DIVthat gets updated every 10 seconds. The
problem is that unless the browser is configured to get new pages at
all times, it displays the page from cache.
Is there a way to prevent this from happenning ?Yes, use a unique URL by adding a timestamp to the URL.
if you can get to the headers, you can help it too... here is a snippet of
code from my PHP generating pages:
//IE actually caches ajax pages. Just another reason to hate that browser.Hate a browser because it doesn''t act the way you want it to instead of
learning how to code it. Intuitive.
header("Expires: Sun, 19 Nov 1978 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache")There is still no guarantee even setting the headers. Adding a timestamp
to the URL is proven to be reliable.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
这篇关于页面上的Ajax缓存......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!