Ajax is “broken” in iOS6

In iOS6, POST requests over XHR seem to be cached quite aggressively. Luckily, it’s fixable:

After a bit of investigation, turns out that Safari on iOS6 will cache POSTs that have either no Cache-Control headers or even Cache-Control: max-age=0.

The only way I’ve found of preventing this caching from happening at a global level rather than having to hack random querystrings onto the end of service calls is to set Cache-Control: no-cache.

Don’t break the web, right?

Is Safari on iOS 6 caching $.ajax results? →
Understanding the iOS6 AJAX bugs →

Using CORS with All (Modern) Browsers

Cross-Origin Resource Sharing (CORS) works by adding a special header to responses from a server to the client. If a response contains the Access-Control-Allow-Origin header, and if the browser supports CORS, then there is a chance you can load the resource directly with Ajax – no need for a proxy or JSONP hacks.

Using CORS with All (Modern) Browsers →