1 |
|
2 | var s = caches.default;
|
3 | async function a(t, e) {
|
4 | let n = e || t.request, o = typeof n != "string" && n.method === "HEAD";
|
5 | o && (n = new Request(n, {method: "GET"}));
|
6 | let r = await s.match(n);
|
7 | return o && r && (r = new Response(null, r)), r;
|
8 | }
|
9 | function c(t, e, n) {
|
10 | let o = n || t.request;
|
11 | return (typeof o == "string" || o.method === "GET") && i(e) && (e.headers.has("Set-Cookie") && (e = new Response(e.body, e), e.headers.append("Cache-Control", "private=Set-Cookie")), t.waitUntil(s.put(o, e.clone()))), e;
|
12 | }
|
13 | function i(t) {
|
14 | if (t.status === 206 || ~(t.headers.get("Vary") || "").indexOf("*"))
|
15 | return !1;
|
16 | let n = t.headers.get("Cache-Control") || "";
|
17 | return !/(private|no-cache|no-store)/i.test(n);
|
18 | }
|
19 | function p(t) {
|
20 | return (e, n) => e.respondWith(a(e, n).then((o) => o || t(e).then((r) => c(e, r, n))));
|
21 | }
|
22 | function l(t) {
|
23 | addEventListener("fetch", p(t));
|
24 | }
|
25 |
|
26 |
|
27 | exports.Cache = s;
|
28 | exports.isCacheable = i;
|
29 | exports.listen = l;
|
30 | exports.lookup = a;
|
31 | exports.reply = p;
|
32 | exports.save = c; |
\ | No newline at end of file |