HTML缓存历史记录 [英] HTML cache history back

查看:330
本文介绍了HTML缓存历史记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我使用 history.back()按钮按下,会发生什么情况?

HTML内容可以从浏览器的本地历史记录或缓存中显示出来,而不需要浏览器向服务器请求?或者浏览器会根据浏览器历史记录中的URL向服务器请求?

解决方案

调用history.back )在JavaScript中与点击浏览器用户界面中的后退按钮相同(但是,如果当前查看的位置包含框架并且已经导航,那么可能存在细微的差异,如果您是迂腐的)。

b
$ b

至于结果来自服务器还是缓存:取决于用户代理(浏览器)。规范(RFC 2616第13.13节, http://256stuff.com/gray/docs /rfc2616/13.html#13.13 )说:


历史机制和缓存是
不同的。特别是
机制的历史不应该试图显示一个资源的
当前状态的
语义透明视图。相反,
历史记录机制旨在显示用户在检索资源时在
时看到的


但是,用户代理执行质量不同。例如,Mozilla / Firefox的相关元错误可以在 https:// bugzilla中找到。 mozilla.org/show_bug.cgi?id=288462



如果您尝试返回的页面具有合适的缓存标题,它将会从缓存而不是从服务器获取。


If I use history.back() for button press then what will happen?

Will the HTML content be displayed from the local history of the browser or the cache and without the browser requesting to the server? Or will the browser request to the server based on the URL that resides in history of browser?

解决方案

Calling "history.back()" in JavaScript is the same as hitting the back button in the browser's user interface (however, there can be slight differences if the currently viewed location contains frames and those have been navigated, if you're pedantic).

As for if the result comes from the server or "cache": it's up to the user agent (browser). The specification (RFC 2616 section 13.13, http://256stuff.com/gray/docs/rfc2616/13.html#13.13) says:

History mechanisms and caches are different. In particular history
mechanisms SHOULD NOT try to show a semantically transparent view of the
current state of a resource. Rather, a history mechanism is meant to show
exactly what the user saw at the time when the resource was retrieved.

However, the user agent implementation quality differs. For example, the relevant meta bug for Mozilla/Firefox can be found at https://bugzilla.mozilla.org/show_bug.cgi?id=288462

If the page you're trying to "back" to has suitable caching headers, it will be fetched from a cache instead of from the server.

这篇关于HTML缓存历史记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆