最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin8浏览0评论

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.

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.

Share Improve this question edited May 23, 2017 at 10:29 CommunityBot 11 silver badge asked Jul 5, 2014 at 19:15 laggingreflexlaggingreflex 34.7k36 gold badges144 silver badges200 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 6

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?

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论