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

workbox.cacheableResponse.Plugin #2051

Closed
jitendra1607 opened this issue May 1, 2019 · 1 comment
Closed

workbox.cacheableResponse.Plugin #2051

jitendra1607 opened this issue May 1, 2019 · 1 comment

Comments

@jitendra1607
Copy link

using /workbox-cdn/releases/4.3.0/workbox-sw.js

i am returning header(X-Is-Cacheable: yes) in response to my api call.
below is my custom service code.
workbox.routing.registerRoute( /http:\/\/127\.0\.0\.1\/lumen/, new workbox.strategies.CacheFirst({ cacheName: 'api-cache', plugins: [ new workbox.cacheableResponse.Plugin({ statuses: [200], headers: { 'X-Is-Cacheable': 'yes', }, }) ] }), 'GET' )
Issue is that 'api-cache' is being created for headers (X-Is-Cacheable: no) and also there is no response data being save for responses having (X-Is-Cacheable: yes) header.

@jeffposnick
Copy link
Contributor

It looks like you're making a CORS request to the third-party origin http://127.0.0.1/. Because you're using CORS, there are limits on the headers that are exposed on your Response objects by default.

You can override those limits by explicitly adding a Access-Control-Expose-Headers: X-Is-Cacheable header to your server-generated response, along with the X-Is-Cacheable: yes header.

You can read more about how this works at https://fetch.spec.whatwg.org/#http-access-control-expose-headers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants