aboutsummaryrefslogtreecommitdiff
path: root/files/de/web/api/cache/add/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/de/web/api/cache/add/index.html')
-rw-r--r--files/de/web/api/cache/add/index.html106
1 files changed, 106 insertions, 0 deletions
diff --git a/files/de/web/api/cache/add/index.html b/files/de/web/api/cache/add/index.html
new file mode 100644
index 0000000000..778820ca66
--- /dev/null
+++ b/files/de/web/api/cache/add/index.html
@@ -0,0 +1,106 @@
+---
+title: Cache.add()
+slug: Web/API/Cache/add
+translation_of: Web/API/Cache/add
+---
+<p>{{APIRef("Service Workers API")}}</p>
+
+<p><span class="seoSummary">Die <strong><code>add()</code></strong> Methode des {{domxref("Cache")}} Interface nimmt eine URL, ruft sie ab und fügt das resultierende Objekt zum gegebenen Cache. </span>Die <code>add()</code> Methode gleicht funktional dem folgenden:</p>
+
+<pre class="brush: js">fetch(url).then(function(response) {
+ if (!response.ok) {
+ throw new TypeError('bad response status');
+ }
+ return cache.put(url, response);
+})</pre>
+
+<p>Für komplexere Operationen müssen Sie {{domxref("Cache.put","Cache.put()")}} direkt verwenden.</p>
+
+<div class="note">
+<p><strong>Hinweis</strong>: <code>add()</code> wird alle zuvor im Cache gespeicherten Schlüssel-Wert-Paare die der Request gleichen überschreiben.</p>
+</div>
+
+<h2 id="Syntax">Syntax</h2>
+
+<pre class="sytaxbox"><em>cache</em>.add(<em>request</em>).then(function() {
+ // request wurde dem Cache hinzugefügt
+});
+</pre>
+
+<h3 id="Parameter">Parameter</h3>
+
+<dl>
+ <dt>request</dt>
+ <dd>Die Request, die dem Cache hinzugefügt werden soll. Dies kann ein {{domxref("Request")}} Objekt oder eine URL sein.</dd>
+</dl>
+
+<h3 id="Rückgabewert">Rückgabewert</h3>
+
+<p>Eine {{jsxref("Promise")}}, die auf void auflöst.</p>
+
+<h3 id="Exceptions">Exceptions</h3>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col"><strong>Exception</strong></th>
+ <th scope="col"><strong>Tritt auf wenn</strong></th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><code>TypeError</code></td>
+ <td>
+ <p>Das URL-Schema nicht <code>http</code> oder <code>https</code> ist.</p>
+
+ <p>Der Antwortstatus ist nicht im 200 Bereich (d.h. keine erfolgreiche Antwort) Dies tritt auf, wenn die Request nicht erfolgreich zurückgegeben wird aber auch wenn die Request eine <em>cross-origin no-cors</em> Request ist (In diesem Fall ist der Status immer 0.)</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Beispiele">Beispiele</h2>
+
+<p>Dieser Codeblock wartet darauf, dass ein {{domxref("InstallEvent")}} ausgelöst wird, ruft dann {{domxref("ExtendableEvent.waitUntil","waitUntil()")}} auf, um den Installationsprozess der Applikation einzuleiten. Dies beinhaltet den Aufruf von {{domxref("CacheStorage.open")}} um einen neuen Cache zu erstellen, um dann mittels {{domxref("Cache.add")}} etwas zu diesem hinzuzufügen.</p>
+
+<pre class="brush: js">this.addEventListener('install', function(event) {
+ event.waitUntil(
+ caches.open('v1').then(function(cache) {
+ return cache.add('/sw-test/index.html');
+ })
+ );
+});
+</pre>
+
+<h2 id="Spezifikationen">Spezifikationen</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('Service Workers', '#dom-cache-add', 'Cache: add')}}</td>
+ <td>{{Spec2('Service Workers')}}</td>
+ <td>Erstdefinition.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browserkompatibilität">Browserkompatibilität</h2>
+
+<div>
+
+
+<p>{{Compat("api.Cache.add")}}</p>
+</div>
+
+<h2 id="Weiterlesen">Weiterlesen</h2>
+
+<ul>
+ <li><a href="https://developer.mozilla.org/de/docs/Web/API/Service_Worker_API/Using_Service_Workers">Service-Worker benutzen</a></li>
+ <li>{{domxref("Cache")}}</li>
+ <li>{{domxref("WorkerGlobalScope.caches")}}</li>
+</ul>