When the client gets to a page by hitting the back button, how to make it load a fresh copy instead of cached one?

血红的双手。 提交于 2019-12-13 13:30:22

问题


I'm trying to get a page to load a fresh copy from server when the client arrives at it by hitting the back button. By default it loads the old cached copy from browser memory.

Is there a way to do that? (in node.js)

Adding an empty function to window.unload as mentioned here doesn't work for me.


回答1:


Tried all the Meta tags, they have no effect. But the question referred to by @BenJ mentions "when you don't have access to the web server's headers".. I actually do have access to and can set whatever headers from server-side. SO I dug out this answer which worked flawlessly

res.header('Cache-Control', 'private, no-cache, no-store, must-revalidate');
res.header('Expires', '-1');
res.header('Pragma', 'no-cache');



回答2:


have you tried using these in the <head> section of your page:

<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="-1" />

Update

refer to this question on SO: Using <meta> tags to turn off caching in all browsers?



来源:https://stackoverflow.com/questions/24589771/when-the-client-gets-to-a-page-by-hitting-the-back-button-how-to-make-it-load-a

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!