iOS 6 GM HTTP POST Cache Bug

In RFC 2616 (chapter 9.5) is clearly written that it is not allowed to cache POST requests, unless the response includes appropriate Cache-Control or Expires header fields. In iOS 6 it seems apple cache sometimes POST requests.

In iOS 6 Apple also implemented the ability to debug websites via USB & your desktop browser like Chrome for Android. With this new feature it is easy to debug such problems.

Here you see a screenshot which shows this XHR POST request (grey marked) with new tool:

The marked post request looks like an uncached request which goes to the remote server. But that’s not the truth. The request doesn’t contact the remote server – it only returns some old cached data. So don’t believe in the new remote debugging tool. Here it shows fictional rows/data.

Here you see the request in detail:

The response date in the header is some minutes old and also the data shown is not up-to-date.

The problem occurs in Safari browser and in the UIWebView. And it seems that the caching only occurs in the loading phase of a website. Perhaps Apple tried to improve the loading time of some sites but have forgotten that it is not allowed to cache HTTP POST requests.

Solution (Server-Side)

It works correctly if you add the header fields you normally use on HTTP GET requests to avoid caching.

Cache-Control: no-cache
Expires: Thu, 01 Jan 1970 00:00:00 GMT