4

Is there a way to use JavaScript to dynamically inject files into the applicationCache? I have seen some references to an applicationCache.add() function, but I can't find any documentation for it and it doesn't exist on the window.applicationCache object in my testing with Chrome.

I have a web application I'm working on that based on a decision needs to inject files into applicationCache. Unfortunately this application doesn't have a traditional server-side component (it's basically static files and JS that communicates with a data source), so I can't just create a dynamic manifest file using something like PHP.

Is there any way to do this?

Thanks!

8three
  • 661
  • 1
  • 5
  • 10
  • You could use `localStorage` instead to store the file contents, then then use them as resources from there using Data URIs. – CBroe May 07 '14 at 18:45
  • 1
    The `add()` method your hear about is not part of the HTML5 Offline Applications specifications at all. It seems it is an [internal method](https://developer.mozilla.org/en-US/docs/nsIDOMOfflineResourceList#add.28.29) used by the Chrome engine in Firefox. – Epoc Feb 17 '15 at 09:27

1 Answers1

1

How you can read below, doesn't exist an applicationCache.add() function, you can only update your manifest, so invalidate the cache

reference

[Exposed=Window,SharedWorker]
interface ApplicationCache : EventTarget {

  // update status
  const unsigned short UNCACHED = 0;
  const unsigned short IDLE = 1;
  const unsigned short CHECKING = 2;
  const unsigned short DOWNLOADING = 3;
  const unsigned short UPDATEREADY = 4;
  const unsigned short OBSOLETE = 5;
  readonly attribute unsigned short status;

  // updates
  void update();
  void abort();
  void swapCache();

  // events
           attribute EventHandler onchecking;
           attribute EventHandler onerror;
           attribute EventHandler onnoupdate;
           attribute EventHandler ondownloading;
           attribute EventHandler onprogress;
           attribute EventHandler onupdateready;
           attribute EventHandler oncached;
           attribute EventHandler onobsolete;
};
ale
  • 10,012
  • 5
  • 40
  • 49