简体   繁体   中英

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

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.

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');

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM