Urara-Blog/node_modules/.pnpm-store/v3/files/1f/4b8193258116c1fe6e534047fed71541f45effa8167a1b4045f88d67cd029317e5f6ff5300d057d33343b770197f81765c27505ae7defa18bfb970ac998ee3
2022-08-14 01:14:53 +08:00

1 line
No EOL
772 B
Text

async function e(e,t){let n="string"!=typeof t&&"HEAD"===t.method;n&&(t=new Request(t,{method:"GET"}));let a=await e.match(t);return n&&a&&(a=new Response(null,a)),a}function t(e,t,n,o){return("string"==typeof t||"GET"===t.method)&&a(n)&&(n.headers.has("Set-Cookie")&&(n=new Response(n.body,n)).headers.append("Cache-Control","private=Set-Cookie"),o.waitUntil(e.put(t,n.clone()))),n}var n=new Set([200,203,204,300,301,404,405,410,414,501]);function a(e){if(!n.has(e.status)||~(e.headers.get("Vary")||"").indexOf("*"))return!1;let t=e.headers.get("Cache-Control")||"";return!/(private|no-cache|no-store)/i.test(t)}function o(n){return async function(a,o){let r=await e(n,a);if(r)return r;o.defer((e=>{t(n,a,e,o)}))}}export{a as isCacheable,e as lookup,t as save,o as sync};