From af3288b106f44aaaa2c80d499ec669383d6f7203 Mon Sep 17 00:00:00 2001 From: MDN Date: Wed, 1 Sep 2021 00:52:00 +0000 Subject: [CRON] sync translated content --- files/fr/web/api/caches/index.html | 80 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 files/fr/web/api/caches/index.html (limited to 'files/fr/web/api/caches') diff --git a/files/fr/web/api/caches/index.html b/files/fr/web/api/caches/index.html new file mode 100644 index 0000000000..b5b57df7ee --- /dev/null +++ b/files/fr/web/api/caches/index.html @@ -0,0 +1,80 @@ +--- +title: WindowOrWorkerGlobalScope.caches +slug: Web/API/caches +translation_of: Web/API/WindowOrWorkerGlobalScope/caches +original_slug: Web/API/WindowOrWorkerGlobalScope/caches +--- +

{{APIRef()}}{{SeeCompatTable}}

+ +

La propriété en lecture seule  caches de l'interface {{domxref("WindowOrWorkerGlobalScope")}} retourne l'objet {{domxref("CacheStorage")}} associé au contexte actuel. Cet objet permet de stocker des ressources pour une utilisation hors-ligne et de générer des réponses personnalisées à des requêtes.

+ +

Syntaxe

+ +
var myCacheStorage = self.caches; // ou simplement caches
+
+ +

Value

+ +

Un objet de type {{domxref("CacheStorage")}}.

+ +

Exemple

+ +

L'exemple suivant montre comment mettre en cache un contexte de service worker pour stocker des ressources et les utiliser hors-ligne.

+ +
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'
+      ]);
+    })
+  );
+});
+ +

Spécifications

+ + + + + + + + + + + + + + + + + + + +
SpécificationStatusComment
{{SpecName('Service Workers', '#self-caches', 'caches')}}{{Spec2('Service Workers')}} +

Défini dans un WindowOrWorkerGlobalScope partiel dans la nouvelle spec.

+
{{SpecName('Service Workers')}}{{Spec2('Service Workers')}}Définition initiale.
+ +

Compatibilité des navigateurs

+ + + +

{{Compat("api.WindowOrWorkerGlobalScope.caches")}}

+ +

Voir aussi

+ + -- cgit v1.2.3-54-g00ecf