[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ru/docs/Web/API/Cache/addAll [Back]  [Original]

Cache.addAll() - API | MDN

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

Cache.addAll()

Baseline
Widely available

This feature is well established and works across many devices and browser versions. Its been available across browsers since 2018 ..

:
, . , , .

In this article

addAll() Cache URLS , , . , , .

: addAll() / , , , put() , addAll().

js
cache.addAll(requests[]).then(function() {
  //    
});

requests

Request, .

Promise, void.

TypeError URL http https. 200 (.., ). , , cross-origin no-cors ( , 0).

InstallEvent, waitUntil . CacheStorage.open , addAll() .

js
this.addEventListener("install", function (event) {
  event.waitUntil(
    caches.open("v1").then(function (cache) {
      return cache.addAll([
        "/sw-test/",
        "/sw-test/index.html",
        "/sw-test/style.css",
        "/sw-test/app.js",
        "/sw-test/image-list.js",
        "/sw-test/star-wars-logo.jpg",
        "/sw-test/gallery/",
        "/sw-test/gallery/bountyHunters.jpg",
        "/sw-test/gallery/myLittleVader.jpg",
        "/sw-test/gallery/snowTroopers.jpg",
      ]);
    }),
  );
});

Specification
Service Workers Nightly
# cache-addAll


Web Proxy Viewer  |  New URL  |  Original Page