Link Web and COVID-19. Click here.

iOS6 Safari Caches ajax post requests

Gary Oosterhuis | October 22, 2012


Recently iOS6 was introduced and with the introduction of any major operation system release it has its bugs. The one that’s got me frustrated at the moment is the ajax POST caching bug in mobile safari. The Apple developers say that this is an intentional addition and is based on standards. We think its a bad decision and a pain to have to deal with when working on future projects and cleaning up old ones.

There are a few simple solutions to manage this caching issue.

The first is to add a random identifier or timestamp to the file being called:

var url = './ajax-file.php?no-cache=' + Date.now();

The second, if using jQuery, is to disable POST caching prior to making an ajax call:

if (/OS 6_/.test(navigator.userAgent)) {
$.ajaxSetup({ cache: false });
}

Link Web Development is a Barrie Website Design and Development company committed to providing quality websites to business owners and other Graphic Design Firms and SEO Experts.

Add a Comment

Your email address will not be published. Required fields are marked *