GoogleChrome / GoogleChrome/workbox

CacheableResponse should accept an array of header values

Open
#3,308 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
13k
Forks
880
Avg merge
2h 44m
Merged PRs (30d)
8

Description

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:

```js
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:

```js
const cacheable = new CacheableResponse({
statuses: [0, 200],
headers: {
'Content-type': ["image/webp", "image/png", "image/jpeg", "image/gif"],
},
});
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.