iOS6 - Is there a way to clear cached ajax POST re

2019-03-13 08:44发布

问题:

iOS6 ajax POST request caching is becoming a huge problem for our webApp. Most of our users have added the app to the home screen. Ever since the upgrade, most of the POST requests to the backend are not working and data is stale from over 6 days ago and counting. We are aware of two workarounds to resolve this, one is to change every POST request so that it's different by adding a timestamp or some random input to it, and the second is to disable caching on the webserver.

Both workarounds are detailed in the following post: Is Safari on iOS 6 caching $.ajax results?

Turning off caching on the webserver would have solved the issue if it was set before the iOS6 upgrade (or right after). However, it seems any POST requests that were made since the upgrade and until the time we turned caching off from apps added to the home screen, are still cached! and we can't find a way to clear them. removing the home screen app and restarting the device doesn't do the trick! The only option we have is to change our URL or to add a timestamp to every request in addition to turning off caching on the webserver.

Does anyone know of a way to clear a home screen app cache, aside from restoring to factory? please provide details.

Warning to anyone who implemented a workaround by adding a timestamp to their requests without turning off caching on the server. If your app is added to the home screen, EVERY post response will now be cached and it doesn't seem to expire. Unless someone has a way to clear it, this looks like a potential memory leak!

回答1:

The only way to consitently beat this cache problem in my experience is to take Google's approach and add a per request id in the url. You can then use mod_rewrite or another such engine for your server to make this transparent for your backend scripts.