MCPcopy Create free account
hub / github.com/SplootCode/splootcode / addFileToCache

Function addFileToCache

packages/runtime-web/serviceworker.ts:15–27  ·  view source on GitHub ↗
(pathname: string, contentType: string, contents: string)

Source from the content-addressed store, hash-verified

13})
14
15async function addFileToCache(pathname: string, contentType: string, contents: string) {
16 caches.open(CacheName).then(function (cache) {
17 const request = pathname
18 const headers = {
19 'Content-Type': contentType,
20 'Cross-Origin-Opener-Policy': 'same-origin',
21 'Cross-Origin-Embedder-Policy': 'require-corp',
22 'Cross-Origin-Resource-Policy': 'cross-origin',
23 }
24 const response = new Response(contents, { status: 200, statusText: 'ok', headers: headers })
25 cache.put(request, response)
26 })
27}
28
29self.addEventListener('fetch', (event: FetchEvent) => {
30 const reqUrl = new URL(event.request.url)

Callers 1

handleNodeTreeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected