我们说我有一个经理页面,它从MySQL数据库中加载了大量信息。
该页面显示了来自其他用户的一堆请求,管理员会逐一查看并逐一标记它们。发生这种情况时,内容在数据库中标记为完整,然后消失。 $(theElement.fadeOut(500))
Information Request
From Bob
Hey, can I get the special report from last Tuesday? Thanks
[reply] [mark complete]
Information Request
From John
The report for Customer #5182 is incomplete. All I have is this:
http://alinktothefile.com/foo Can you send it over? Thanks
[reply] [mark complete]
Information Request
From Mark
Did you want the website to look like this? http://somewebsite123.com
or something else in mind?
[reply] [mark complete]
在其中一些请求中,信息可能包含用户将单击的链接。但是,一旦用户点击浏览器中的后退按钮,显示的内容就是页面最初加载页面时的外观。
所以他们从页面顶部开始,包含他们已经完成的所有内容,而不是实际上正确的信息。
显然,链接可以在新标签页中打开,但是,这不是一个很好的解决方案,尤其是在移动设备上。
解决此问题的可能解决方案是什么,以便即使用户按下后退按钮,动态内容也始终是最新的?
答案 0 :(得分:0)
您可以使用html元标记来停止后退缓存。
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="pragma" content="no-cache" />
或者您可以在服务器端代码中执行此操作
response.setHeader("cache-control", "max-age=0,no-cache, no-store, must-revalidate");
response.setHeader("Pragma", "no-cache"); // HTTP 1.0
response.setHeader("Expires", "0"); // Proxies.
参考此
Using <meta> tags to turn off caching in all browsers?
http://cristian.sulea.net/blog.php?p=2014-01-14-disable-browser-caching-with-meta-html-tags