douzhong1730
2012-06-08 13:10
浏览 11
已采纳

如何仅缓存后退按钮

Can someone explain to me how to set a cache for my page that if the user hits the back button and is offline or something then he will still see the previous page like on SO and most sites.

But how can i force that when a new HTTP request is sent, it will fetch a new one since the content changes by the minute (ie a forum)?

Thanks

图片转代码服务由CSDN问答提供 功能建议

有人可以向我解释如何为我的页面设置缓存,如果用户点击后退按钮并且离线 或者其他什么,然后他仍然会在SO和大多数网站上看到上一页。

但是我怎么能强制在发送新的HTTP请求时,它将获取一个新的,因为 内容按分钟变化(即论坛)?

谢谢

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dphnn333971 2012-06-10 18:05
    已采纳

    I have finally discovered that for some reason putting a cache on all my pages, will let them have a back button forever, however when the page is refreshed, it will still fetch a new one from the server.

    Wierd, but it works!

    点赞 打赏 评论
  • doushi1510 2012-06-08 13:23

    The only way to really do this is to inform the client browser that it can cache the webpage, which will (sometimes) prevent the browser from sending another HTTP Request if the cache time has not expired (see here for more: http://en.wikipedia.org/wiki/Web_cache#Cache_control).

    However, if the content of the page is dynamic and continuously refreshing (as you seem to imply if it is a forum). Then you probably don't want to allow the browser to cache at all.

    点赞 打赏 评论

相关推荐 更多相似问题