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

后端 未结 6 1874
难免孤独
难免孤独 2021-02-02 09:22

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, th

相关标签:
6条回答
  • 2021-02-02 09:49

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

    0 讨论(0)
  • 2021-02-02 09:55

    This drove me absolutely nuts. I tried killing Safari, clearing the cache, switching to private mode, and removing the web app from the home screen. None of those work, but what does work is temporarily loading the web app page in Safari itself and reloading.

    If you're using add to home screen, you can add ?web_app_ready=1 to the install URL. Since that's not an end user procedure, adding a query string to every script (the answer above) will probably be more effective for non-developer environments.

    0 讨论(0)
  • 2021-02-02 09:57

    Building off of what SquareFeet said, one could automatically pull the new file down every time with a unique GET tag appended to the filename, using PHP. For example:

    <link rel="stylesheet" type="text/css" href="/css/global.css?
       <?php echo(mt_rand(10000000, 99999999)); ?>
    " />
    

    Theoretically, the same task could be accomplished using JavaScript, albeit with some modifications to the web server:

    <link rel="stylesheet" type="text/css" href="/css/global.css?
       <div id="id"></div>
    " />
    
    <script language="Javascript" type="text/javascript">
       document.getElementById("id").innerHTML = Math.floor((Math.random() * 10000) + 1);
    </script>
    
    0 讨论(0)
  • 2021-02-02 10:01

    If you are jailbroken, just do this in the terminal

    rm ./Library/Caches/com.apple.webapp/Cache.db
    
    0 讨论(0)
  • 2021-02-02 10:10

    This is a way that worked for me to clear completely the cache:

    1-Delete the tabs in safari where there is your app.
    2-Delete the icon of the app in the home screen.
    3-Kill safari from the memory.
    4-Go to settings/safari and press clear cache.
    5-You can restart your iPhone/iPod if you want to be sure that it works

    0 讨论(0)
  • 2021-02-02 10:11

    I found that using bundling feature in ASP.NET MVC solved this problem for me.

    It automatically generates a bundled link of the form:

    http://www.domain.com/MvcBM_time/bundles/AllMyScripts?v=r0sLDicvP58AIXN_mc3QdyVvVj5euZNzdsa2N1PKvb81

    The token after the v= changes if any file in the bundle changes, guaranteeing that browser requests for the bundle will get the latest bundle.

    0 讨论(0)
提交回复
热议问题