Skip to content

Instantly share code, notes, and snippets.

@wchristian
Created February 24, 2012 16:38
Show Gist options
  • Save wchristian/1901919 to your computer and use it in GitHub Desktop.
Save wchristian/1901919 to your computer and use it in GitHub Desktop.

on IE8 cache: false needs to be obeyed in all ajax requests or maybe even forced

The problem is at this position:

https://github.com/jquery/jquery/blob/master/src/ajax.js#L664

This line skips the logic triggered by cache: false if the request type is anything but HEAD or GET. I assume this is done for optimization, because most browsers won't cache on other types of requests.

However IE8 does not play by those rules.

I was in this situation:

host.tld/foo was first loaded as a normal GET request via the browser address bar. Modifications to the server session were then done via other ajax requests. Finally a POST request without any parameters was done to host.tld/foo, which would normally start processing of the data in the server session.

IE8 however did not even hit the server and instead delivered the cache of the GET request to host.tld/foo to jquery's ajax function, which expected a JSON reply and simply threw a "Syntax Error" when faced with HTML.

Normally this would be fixed easily with cache: false, but since that option is ignored on requests other than HEAD or GET i had to modify the url manually, which resolved the situation. As such, the logic should be modified to either of these options:

  1. obey cache option on all request types
  2. obey cache option on all request types in IE8
  3. force cache option on all request types in IE8

Personally i would prefer c., since it would transparently work around this IE bug for other users, but i do not know how feasible it is.

Note: This is with a real IE8 on WinXP, not IE9 in compatibility mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment