有没有一种方法可以使用JavaScript将文件动态注入(inject)到applicationCache中?我已经看到一些对applicationCache.add()函数的引用,但是我找不到关于它的任何文档,并且在我用Chrome进行的测试中,它不存在于window.applicationCache对象中。

我有一个正在处理的Web应用程序,它是根据需要将文件注入(inject)applicationCache的决定来进行的。不幸的是,该应用程序没有传统的服务器端组件(基本上是静态文件和与数据源通信的JS),因此我不能仅使用PHP之类的文件来创建动态 list 文件。

有什么办法吗?

谢谢!

最佳答案

您如何在下面阅读,不存在applicationCache.add()函数,您只能更新 list ,因此会使缓存无效

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;
};

09-27 07:19