I am trying to mark resources that are being stored in the service worker cache.
I thought it would be possible to add a custom header to the resource that could indica
You would have to create a new response to do this:
fetch('./').then(response => {
console.log(new Map(response.headers));
const newHeaders = new Headers(response.headers);
newHeaders.append('x-foo', 'bar');
const anotherResponse = new Response(response.body, {
status: response.status,
statusText: response.statusText,
headers: newHeaders
});
console.log(new Map(anotherResponse.headers));
});
Live demo (see the console)