Chrome History API Issues

I have problems with the Chrome site.

Most sites use ajax / xmlhttprequest to load pages and history APIs to enable the back button. Only the content of the page changes with the request, menu, etc. Never reboots. This simply repeats the ajax request for the previous page. All this works fine until someone clicks the back button after viewing the blog. The blog is not loaded by ajax, it is just a standard link.

In Firefox, if I go to the blog, return the site correctly. The main page with the loaded navigation, as well as the page that needs to be viewed inside it.

In Chrome, however, if I click the back button from the blog, the "external" page will not load, only the contents of the ajax request will be indicated. You may need to look through it to fully understand.

Is this a bug in Chrome or my job? It seems that I cannot return to the page partially loaded with xmlhttprequest, since only the loaded object is loaded.

The site is here: http://www.basmooarc.com

thanks

Ric

+6
source share
1 answer

short answer

Add the Cache-Control: no-store HTTP header for XHR responses.

long answer

I am sure this is a bug in Chrome. I found the same error in my application and it works fine in Firefox, but breaks in Chrome. I think the problem is that Chrome caches the XHR response and serves it from the cache when the back button is clicked. My application uses Etags, but Chrome did not bother to check Etag. It just uses a cached response that lacks all external content. The best solution I came up with is to add a no-store to the XHR response cache management header.

You can see the behavior on the "Clean Chrome Internal Page" page. Type chrome://net-internals in the URL bar, open the Events tab and follow the steps to reproduce your error. When you go to the page without an ajax, and then click the "Back" button, you will see a URL_REQUEST entry for the URL of the page you are trying to go to, but Chrome just checks the cache and that it is. Compare this to a regular request to this URL. The normal one will have a cache check and then the HTTP_TRANSACTION_SEND_REQUEST section in which Chrome makes the actual HTTP request.

+4
source

Source: https://habr.com/ru/post/902188/


All Articles