如何在主屏幕上清除IOS Web App的缓存? [英] How can I clear the cache of an IOS Web App on the Homescreen?
问题描述
我正在使用JQTouch在主屏幕上使用元标记apple-mobile-web-app-capable创建Web应用程序,但无论我在设置中清除缓存多少次,Web App的Javascript仍然是较旧的缓存版本。
I am using JQTouch to create a Web App on the Homescreen using meta tag "apple-mobile-web-app-capable", but no matter how many times I clear the cache from within Settings, the Web App's Javascript is still an older cached version.
奇怪的是,如果我将元标记的内容设置为;
Strangely enough, if I set the meta tag's content to;
<meta name="apple-mobile-web-app-capable" content="no" />
...然后将Web App添加到主屏幕,我在启动它时获得最新版本。
...then add the Web App to the Homescreen, I get the latest version when I launch it.
然而,如果我将元标记设置为;
Yet if I set the meta tag to;
<meta name="apple-mobile-web-app-capable" content="yes" />
...然后将Web App添加到主屏幕,我得到较旧的缓存版本。
...then add the Web App to the Homescreen, I get the older cached version.
PS。我可以确认只有javascript 不会刷新。
PS. I can confirm that is only the javascript which will not refresh.
推荐答案
你可以尝试添加一个js末尾的唯一字符串包括src属性(例如,使用时间戳)。请记住,您必须为每个要执行的刷新更改此唯一字符串,因此您可能需要考虑进行延迟加载(这本身可以解决您的问题):
< script type =text / javascriptsrc =myScript.js?012345>< / script>
You could try adding a unique string to the end of your js include's src attribute (use a timestamp, for example). Bear in mind you'll have to change this unique string for each refresh you want to do, so you may want to consider doing lazy-loading (which may in itself solve your problem):
<script type="text/javascript" src="myScript.js?012345"></script>
这通常强制浏览器抓取最新版本的脚本。可能会工作......
This usually forces the browser into grabbing the latest version of the script. Might work...
这篇关于如何在主屏幕上清除IOS Web App的缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!