Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Back Button (Browser Behavior)

When the back button is pressed in a web browser, is the default action to send a get request or serve from the browsers history?

If its browser specific, what would the default actions be for Internet Explorer and Firefox?

like image 801
MichaelICE Avatar asked Nov 04 '09 15:11

MichaelICE


People also ask

What does the browser “back” button actually do?

And therein lies the rub: the browser “Back” button takes the user back to their previously visited URL, which isn’t necessarily the same as what the user perceived to be their previously visited page.

How do I Make my Back button work with browsing history?

In summary: Use history.pushState () to make sure your site invokes ‘back’ button behavior that aligns with the user’s expectations. Specifically, ensure that any visual change the user will perceive as a new page is added to their browsing history, regardless of whether it’s technically a new page or not.

Why does the back button give us the previous page first?

a browser always stored the pages for its remembering and when we press the back button it doesn't send the request to server for the previous page instead it just see its cache where it stored the pages and it follow the LIFO rule that is why it give us that page first on pressing the back button which we opened in the last

Why do users expect the “back” button to take them back?

The short version: users expect the “Back” button to take them back to what they perceived to be their previous page.


2 Answers

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.

like image 157
Ben S Avatar answered Sep 30 '22 20:09

Ben S


I just tested this in Chrome and Firefox for fun

When I press back in Chrome on a Google search page, no requests happen. The browser pulls from cache.

In Firefox, I actually get a 204 No Content with the path being http://clients1.google.ca/generate_204 from Google.

I found this using Charles proxy so it's nothing scientific :)

like image 35
Bartek Avatar answered Sep 30 '22 21:09

Bartek