from Hacker News

The HTML5 appcache is the New Bootloader

by penguindev on 6/29/14, 8:53 PM with 15 comments

  • by jwise0 on 6/29/14, 10:15 PM

    This seems like a pretty bizarre solution. Careful design of updates to be resilient to ordering errors seems like the appropriate response here -- for instance, using the remote site like a content-addressible cache, rather than a name-addressible cache.

    In response to a cache that provides only bare minimums for functionality, the author seems to be suggesting throwing away all the the cache logic that browser vendors have gone to implement for you, and instead rewriting one's own cache atop LocalStorage and IndexedDB. This seems like a pretty concerning reaction -- or am I simply misreading the author's conclusion?

  • by Lerc on 6/30/14, 12:20 AM

    I had a play around in this area a few years ago. I had a tiny index.html that had just this script in the body.

      var s=localStorage["bootstrap"];
      if (s) {eval(s);} else {
        var t="But you are not carrying the axe!<br>";
    	  t+='<a href="loadup.html">Get the Axe</a>';
    	  document.body.innerHTML=t;
       }
    
    
    http://fingswotidun.com/notanos/

    Ultimately I found that I needed a server side because of URLs and the same-origin policy. There were just some things that browsers expected to fetch from a URL rather than have the data arrive by other means.

    For a time I used a WebDav server to be a dumb server. Eventually the system evolved into https://github.com/Lerc/notanos Which uses it's own custom server https://github.com/Lerc/userserv which uses your unix login and statically serves files that your logged-in user is allowed to see.

  • by timothya on 6/30/14, 12:20 AM

    AppCache is notoriously broken[0] (or really hard to work with), which is one of the reasons that the new ServiceWorker API was created[1]. ServiceWorker allows you to run a script in the background that can intercept network requests for specified paths, allowing you to create a pretty solid offline strategy (it also does some other interesting things, like push notifications, geofencing, and background sync).

    There was a short video about ServiceWorker at the recent Google I/O that you can check out for an overview[2].

    [0]: http://alistapart.com/article/application-cache-is-a-doucheb...

    [1]: https://github.com/slightlyoff/ServiceWorker/blob/master/exp...

    [2]: https://www.youtube.com/watch?v=4uQMl7mFB6g

  • by aikah on 6/29/14, 10:45 PM

    Ok everybody says the spec is broken.But the spec is not being fixed either.

    The OP says : only put index.html in the appcache file.

    But what about if I want my app to work offline,do I really need to go and shove everything in local storage?

    So what's the point of appcache then ? and who went along with that spec at first place?

    This specific issue infuriates me.It makes creating offline web app so complicated ,it's like the people writing the spec didnt want developpers to write offline apps.

    Just fix the damn spec.

  • by jamescun on 6/29/14, 11:06 PM

    I don't understand what need the appcache system fulfils. Within HTTP there is already a reasonable caching system. True, as mentioned in the post, the browser may occasionally clear the cache or elements of it; but that would be an argument for adding something like a `persist` flag to the `Cache-Control` header which would serve the exact same purpose, in addition to being backwards compatible with older browsers.