google-chromescrollscroll-position

Chrome not retaining scroll position on back button


On most (static) websites, browsers will retain the user's previous scroll position when going back to a previous page.

On my site, Firefox, Safari, and Edge all exhibit this behavior, by default. But Chrome does not. Why?

My app is built on tornado and we use jinja2 to render static pages, so I wouldn't expect there to be an issue due to an AJAX-heavy web framework.

I have tried modifying the cache headers to see if it was a caching issue, as suggested here, but no luck. I also don't have the overflow: auto issue suggested in that post.

Here are my response headers:

HTTP/1.1 200 OK
Date: Fri, 09 Nov 2018 18:11:20 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Server: *
Etag: W/"<etag>"
Cache-Control: private
Content-Encoding: gzip

Solution

  • <facepalm>

    I was focusing an element on page load that is at the top of the screen, which causes Chrome to scroll to the element. Not sure why Firefox/Safari/Edge behave differently.