CacheableResponse should accept an array of header values
alexandernst opened this issue · comments
Welcome! Please use this template for reporting bugs or requesting features. For questions about using Workbox, the best place to ask is Stack Overflow, tagged with [workbox]
: https://stackoverflow.com/questions/ask?tags=workbox
Library Affected:
_workbox-cacheable-response
Browser & Platform:
all browsers
Issue or Feature Request Description:
Currently, the CacheableResponse
has two properties (statuses
and headers
), which can be used to cache responses conditionally. As per the example in the documentation:
const cacheable = new CacheableResponse({
statuses: [0, 200],
headers: {
'X-Is-Cacheable': 'true',
},
});
If the response is either 200
OR an opaque response and the headers contain a header named X-Is-Cacheable
and the value of that header is true
, then the response will be cached.
Note however that it's currently impossible to specify several values for the same header. E.g. I'd like to be able to do the following:
const cacheable = new CacheableResponse({
statuses: [0, 200],
headers: {
'Content-type': ["image/webp", "image/png", "image/jpeg", "image/gif"],
},
});