问题
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