在返回时从缓存中读取页面,但在单击页面链接时不读取页面

发布于 2024-10-02 02:03:38 字数 303 浏览 0 评论 0原文

我有一组相互链接的动态网页。

当用户从一个页面单击到另一个页面时,我不希望发生任何缓存 - 请求必须发送到服务器,服务器将返回最新的页面。

但是,当用户单击“后退”时,我确实希望使用缓存 - 某些页面可能需要一些时间才能生成,当您单击它们时这很好,但当您单击它们时就不行了重新单击“返回”。

这可能吗?

(请不要建议将所有内容重新设计为进行 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一绘本一梦想 2024-10-09 02:03:38

处理动态页面时避免浏览器缓存的一个常见技巧是向链接 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文