Prevent iOS 6 from Caching Ajax POST Requests

How to fix it: There are various methods to prevent caching of requests. The recommended method is adding a no-cache header.

This is how it is done.

jQuery:

Check for iOS 6.0 and set Ajax header like this.

$.ajaxSetup({ cache: false });

ZeptoJS :

Check for iOS 6.0 and set Ajax header like this.

$.ajax({
type: 'POST',
headers : { "cache-control": "no-cache" },
url : ,
data:,
dataType : 'json',
success : function(responseText) {…}

Server side

Java :

httpResponse.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");

Make sure to add this at the top the page before any data is sent to the client.

.NET

Response.Cache.SetNoStore();

Or

Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);

PHP

header('Cache-Control: no-cache, no-store, must-revalidate'); // HTTP 1.1.
header('Pragma: no-cache'); // HTTP 1.0.