简体   繁体   English

iOS6 - 有没有办法清除缓存的ajax POST请求添加到主屏幕的webapp?

[英]iOS6 - Is there a way to clear cached ajax POST requests for webapp added to home screen?

iOS6 ajax POST request caching is becoming a huge problem for our webApp. iOS6 ajax POST请求缓存对我们的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. 自升级以来,大多数对后端的POST请求都不起作用,数据在6天前就已过时且数不胜数。 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. 我们知道要解决这个问题的两个解决方法,一个是更改每个POST请求,以便通过向其添加时间戳或一些随机输入来改变它,第二个是禁用Web服务器上的缓存。

Both workarounds are detailed in the following post: Is Safari on iOS 6 caching $.ajax results? 以下文章详细介绍了这两种解决方法: iOS 6上的Safari是否缓存$ .ajax结果?

Turning off caching on the webserver would have solved the issue if it was set before the iOS6 upgrade (or right after). 如果在iOS6升级之前(或之后)设置,则关闭Web服务器上的缓存可以解决问题。 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! 但是,似乎任何自升级以来所做的POST请求,直到我们从添加到主屏幕的应用程序转为缓存时,仍然会被缓存! 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. 除了关闭网络服务器上的缓存之外,我们唯一的选择是更改我们的URL或为每个请求添加时间戳。

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! 除非有人有办法清除它,否则这看起来像是潜在的内存泄漏!

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. 在我的经验中,唯一能够完全击败此缓存问题的方法是采用Google的方法并在网址中添加每个请求ID。 You can then use mod_rewrite or another such engine for your server to make this transparent for your backend scripts. 然后,您可以使用mod_rewrite或其他此类引擎为您的服务器使后端脚本透明。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM