laggingreflex
laggingreflex

Reputation: 34627

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.

Upvotes: 4

Views: 6672

Answers (2)

laggingreflex
laggingreflex

Reputation: 34627

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

Upvotes: 6

user3794166
user3794166

Reputation:

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?

Upvotes: 0

Related Questions