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

前端 未结 9 840
悲&欢浪女
悲&欢浪女 2021-02-01 05:11

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 s

相关标签:
9条回答
  • 2021-02-01 05:27

    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.

    0 讨论(0)
  • 2021-02-01 05:32

    The only way to deal with this currently is to wait, but there is a workaround. If you change the name of the file, it will pull the new code. However, if you change it back to the old name before the cache clears, the old code will be used. The cache refreshes periodically and will update eventually. I just had this happen to me with a CSS file that refused to change. Time will fix it, but if you just need it to update for testing, a name change will work.

    0 讨论(0)
  • 2021-02-01 05:36

    First plug the phone into the computer then open the web app on the phone and Safari on the computer, then you can open the web inspector in Safari from the menu "Develop>Name of phone>title of app" (if you can't see the develop menu you can turn it on in Safari's preferences).

    From there you can see/edit the cookies and local storage just like sites on your computer and pressing command+r while the inspector is focused will reload the app on the phone.

    0 讨论(0)
  • 2021-02-01 05:37

    You can connect your device and open Safari's web inspector on your computer and run document.location.reload() in the console tab to reload the page.

    Before reloading you can press Option+Command+E to make sure the cache is cleared.

    Instead of above you can also press Shift+Command+R to reload the page without cache but sometimes it hasn't worked for me.

    0 讨论(0)
  • 2021-02-01 05:38

    If the iOS6 device has a jailbreak applied, you can use ssh to delete the content of the folder "/private/var/mobile/Library/Caches/com.apple.webapp".

    Next time that you start the web app, all files will be re-downloaded from the webserver.

    0 讨论(0)
  • 2021-02-01 05:41

    Just set the request you pass to the webview to NSURLRequestReloadIgnoringLocalCacheData

    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; 
    [request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData];
    [self.webView loadRequest:request];
    
    0 讨论(0)
提交回复
热议问题