While it appears that in Apache you can set the "Pragma: no-cache" just for posts on the server side, in IIS the http headers apply to all methods.
I opted for creating a specific HTTP module that sets headers to disable client caching for certain specific requests. Here is the C# code:
using System;
using System.Web;
using System.Text.RegularExpressions;
///
/// HttpModule responsible for setting headers to disable cache in case of posts from iPad+iOS6+Safari. This environment may cache Ajax posts.
///
public class HttpNoCacheModule : IHttpModule
{
// user agent regular expression to capture Safari on iPad iOS 6
private Regex ios6Regex = new Regex(@"iPad.+OS 6.+Safari", RegexOptions.IgnoreCase);
public void Dispose()
{
}
public void Init(HttpApplication app)
{
app.EndRequest += new EventHandler(this.OnEndRequest);
}
private void OnEndRequest(Object source, EventArgs e)
{
HttpApplication application = (HttpApplication)source;
HttpContext context = application.Context;
if (ios6Regex.IsMatch(context.Request.UserAgent))
{
if ("POST".Equals(context.Request.HttpMethod))
{
context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
context.Response.AddHeader("pragma", "no-cache");
context.Response.CacheControl = "no-cache";
}
}
}
}