Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS6 - How to Clear Cache of Homescreen/Standalone Web App?

Tags:

It would appear that Apple have changed the way homescreen/standalone web apps work in iOS 6. According to various blog posts (example) these apps now get their own dedicated space for storing their cached files, sqllite dbs, local storage etc, rather than sharing with the Safari browser like before.

Before iOS 6 when developing I used to go through the following procedure religiously to clear the cache...

  1. Remove app from homescreen.
  2. Close all pages/tabs in Safari.
  3. Finally "Clear Cookies & Data" or "Clear Data" in "Settings" > "Safari".

Unfortunately now that Apple have moved the goal posts this same procedure doesn't seem to work. After clearing, even though my changes are picked up in Safari, when I add to the homescreen and launch the app the old HTML,JS etc is still picked up.

Does anyone know how to reliably fully clear the cache in iOS 6?

like image 296
Oliver Pearmain Avatar asked Oct 10 '12 09:10

Oliver Pearmain


2 Answers

I can't verify the cache being cleared properly but this worked for me :

In order to do this, you need to allow Web Inspector on your iOS device. Go to Settings > Safari > Advanced > Web Inspector (it has to be active) And you have to activate the developer menu on your computer's Safari. Go to Preferences > Advanced > Activate Developer menu

  1. Connect your device to your computer with the USB cable
  2. Go to safari > Developpement > Your Device name > Inspect an App (The app has to be running)
  3. This will open The inspector on your computer for the web app
  4. While the inspector is open Clear the cache (command + alt + E)
  5. With the inspector still open refresh the page on your computer (command + R)

Somehow the Webapp cache got cleared and i got the non-cached code.

like image 138
onemesh Avatar answered Sep 18 '22 16:09

onemesh


I found a a work-around. Just put a link on the web page itself for users who are having trouble seeing new version...

<a href="javascript:top.frames.location.reload();">refresh</a> 

It works just like the iPhone/iPad refresh button on the address bar!

like image 33
John Wolf Avatar answered Sep 19 '22 16:09

John Wolf