当客户端通过按下后退按钮进入页面时,如何使其加载新副本而不是缓存副本?
我正试图通过点击后退按钮获取一个页面,以便在客户端到达时从服务器加载新副本。默认情况下,它从浏览器内存加载旧的缓存副本。
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.
有没有办法做到这一点? (在node.js中)
Is there a way to do that? (in node.js)
将空函数添加到 window.unload
这里提到的对我不起作用。
Adding an empty function to window.unload
as mentioned here doesn't work for me.
尝试了所有Meta标签,它们没有效果。但是问题
b $ b提到
@BenJ
提到当你无法访问网络服务器的标题时..
我实际上有权访问并可以设置服务器端的任何标头。
所以我挖了这个完美无缺的答案
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');