Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone Web App disable cache

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?

Thanks

like image 673
Benoit Avatar asked Dec 02 '09 09:12

Benoit


1 Answers

What meta tags have you tried?

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

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

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 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.

like image 185
GeoNomad Avatar answered Sep 22 '22 01:09

GeoNomad