Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CacheableResponse should accept an array of header values #3308

Open
alexandernst opened this issue Apr 11, 2024 · 0 comments
Open

CacheableResponse should accept an array of header values #3308

alexandernst opened this issue Apr 11, 2024 · 0 comments

Comments

@alexandernst
Copy link

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"],
  },
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant