7

I've encountered a strange bug in Chrome 19. I implemented a full-AJAX website (every non-external link is opened via AJAX request) with pushState support. I transmit the HTML snippets in AJAX via JSON format.

When I leave my site via an external link and then go back, Chrome renders cached data for that URL - the problem is, he caches the JSON content and shows that, instead of full web-page.

This is reproducible by these steps (UPDATE: I removed AJAX functionality on my website since then, so this bug does no longer appear):

  1. Open http://beta.mirtes.cz/
  2. Click on the second date link (16. 6. 2012 next to "It all began with a strange e-mail"). This page (you are now at http://beta.mirtes.cz/it-all-began-with-a-strange-e-mail) is loaded via AJAX.
  3. Click on "It all began with a strange e-mail". You are redirected to an external website.
  4. Click "Back" in Chrome after the page is completely loaded.

I try to send all AJAX responses with Cache-Control: no-cache, but with no effect.

Firefox 12 works OK.

Ondřej Mirtes
  • 5,054
  • 25
  • 36

1 Answers1

7

I came with a workaround - I perform AJAX request with additional dummy GET parameter - ?ajax=1. This way the browser can recognize the difference between usual HTML content and JSON. It doesn't have any impact on the user, the parameter is visible only in Firebug.

Ondřej Mirtes
  • 5,054
  • 25
  • 36
  • Can you explain a little more what you did and how it fixed the problem? – Ryan Aug 16 '12 at 17:49
  • I am making all AJAX requests with additional GET parameter - in this case, ajax=1. This parameter is invisible to the user, because it's performed only in the background. – Ondřej Mirtes Aug 17 '12 at 07:16
  • This way, the browser can know the difference between full HTML content and JSON AJAX content because the URLs are different. And thus it does not shows the cached JSON content where it shouldn't. You can check functionality on my homepage at http://ondrej.mirtes.cz/. – Ondřej Mirtes Aug 17 '12 at 07:17