在返回时从缓存中读取页面,但在单击页面链接时不读取页面
我有一组相互链接的动态网页。
当用户从一个页面单击到另一个页面时,我不希望发生任何缓存 - 请求必须发送到服务器,服务器将返回最新的页面。
但是,当用户单击“后退”时,我确实希望使用缓存 - 某些页面可能需要一些时间才能生成,当您单击它们时这很好,但当您单击它们时就不行了重新单击“返回”。
这可能吗?
(请不要建议将所有内容重新设计为进行 AJAX 查询的单个页面!)
(注意:这个问题与非常流行的“当用户单击“后退”时如何防止缓存?”问题相反。 )
I have a set of interlinked dynamic web pages.
When the user clicks from one page to another, I don't want any caching to happen - the request must go to the server, which will return an up-to-date page.
But when user clicks Back, I do want the cache to be used - some of the pages can take some time to generate, which is fine when you're clicking through to them, but not when you're clicking Back.
Is this possible?
(Please don't suggest re-engineering everything as a single page making AJAX queries!)
(Note: this question is the opposite of the ever-popular "How do I prevent caching when the user clicks Back?" question.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
处理动态页面时避免浏览器缓存的一个常见技巧是向链接 URL 添加一个唯一的参数(使用时间,常见到毫秒)。
当用户点击“后退”按钮时,他们将返回到最后渲染的版本,并且应该从缓存中获取它。
A common trick for avoiding the browser cache when dealing with dynamic pages is to add a parameter to the link url that is unique (using the time, to the millisecond is common).
When the user hits the 'back' button, they will go back to the last rendered version, and should get it from the cache.