iPhone Web App禁用缓存

问题描述:

我使用PHP构建了一个iPhone webapp。主要(也是唯一)页面包含 apple-mobile-web-app-capable apple-touch-fullscreen 元标记,以便一旦添加到该标签就可以全屏运行主屏幕。但是,似乎每次我从主屏幕启动应用程序时,都会使用页面的缓存版本而不是刷新页面(当然,我需要在启动时更新页面,并且不能在这里使用Ajax - 需要使用SSO phpCAS动态验证用户)。我没有使用任何清单文件,并尝试添加有关缓存的元标记,但没有成功。有谁知道如何解决这个问题?

I have built an iPhone webapp using PHP. The main (and only) page includes the apple-mobile-web-app-capable and apple-touch-fullscreen meta tags so that it can run fullscreen once added to the homescreen. However, it seems every time I launch the app from the homescreen, the cache version of the page is used instead of refreshing the page (and of course, I need the page to be updated on startup, and cannot use Ajax here - need to dynamically authenticate the user with SSO phpCAS). I did not use any manifest file and tried adding meta tags about cache without success. Does anybody know how to fix this?

谢谢

什么您尝试过meta标签吗?

What meta tags have you tried?

<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">

应告诉Safari不要缓存,但我还没有尝试过。

should tell Safari not to cache, but I have not tried them.

您可以使用javascript从缓存页面加载真实启动页面,使用任何标准技术使URL唯一,例如添加随机数。

You could use javascript to load your "real" startup page from the cached page using any of the standard techniques to make the URL unique, such as adding a random number.

这甚至可能适用于主要的启动页面,但我对此表示怀疑。值得一试。

That might even work for the main startup page, but I doubt it. Worth a try, though.

我建议缓存页面只有在跳板上才会加载新页面:

I suggest the cached page load a new page only if it is on the springboard:

UNTESTED建议:

UNTESTED suggestion:

window.onload = function () {
   if (navigator.standalone) {
     document.location.href = 'http://your.com/whatever.php?randomjunk=1234')  }
}

所以如果页面在浏览器中,它可以提供有关保存到主屏幕的说明以及是否从主屏幕运行它将加载真实页面。

so if the page is in the browser it can give instructions on saving to the home screen and if it is run from the home screen it will load the real page.