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:
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.
This is browser dependent.
The behavior of the
history.back()
button is up to the browser manufacturer.