How can I clear the cache of an IOS Web App on the Homescreen?

dizietsm4 picture dizietsm4 · Nov 9, 2011 · Viewed 30k times · Source

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" />

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

...then add the Web App to the Homescreen, I get the older cached version.

PS. I can confirm that is only the javascript which will not refresh.

Answer

SquareFeet picture SquareFeet · Nov 22, 2011

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