Last week, we discovered that, Safari in iOS 6 will aggressively cache AJAX POST requests.
There are two popular workarounds that people have proposed:
- Make URLs unique by adding query parameter, such as a timestamp, to the URL.
- Set the header,
Cache-Control: no-cache, in the response
I noticed that some of my POST requests were not getting cached even
though I had neither of these workarounds in place. After some poking
around, I’ve discovered that having
Cache-Control response header also works.
So, before you go adding
no-cache to all of your POST responses, check to
no-store is already getting set.
I’ve published a simple Sinatra app that helped me test this: https://github.com/loganlinn/ajax-post-cache-test