点击back按钮的时候是否会重新向server发起请求

当点击back button的时候,如果前一个页面是GET请求,并且页面没有过期(通过header中的expires判断),直接使用浏览器的缓存,如果页面已经过期则重新发起GET请求, 如果前一个页面是POST请求,则浏览器会询问是否重新发起POST请求。。

Informal Answer

If the previous page was a GET request, the page is typically fetched from the browser's cache unless the cache time on the page has expired (this expiration time is set by the administrators of the web page), or another factor leads the browser to believe the information isn't fresh enough.

If the previous page was a POST request, the browser usually asks you if you'd like to resend the information and the page is fetched from the server.

Formal Answer

This is covered in Section 13 of the HTTP Protocol specification that browsers should implement.

Specifically, 13.10 states that:

Some HTTP methods MUST cause a cache to invalidate an entity. This is either the entity referred to by the Request-URI, or by the Location or Content-Location headers (if present). These methods are:

- PUT
- DELETE
- POST

Other types of requests (such as a GET), may be cached. Read through the full spec if you want the gory details, but the spec is setup in a way that allows the browser to use its cache as much as possible.




http://stackoverflow.com/questions/1674493/back-button-browser-behavior

你可能感兴趣的:(点击back按钮的时候是否会重新向server发起请求)