Workbox: workbox.cacheableResponse.Plugin

Created on 1 May 2019  路  1Comment  路  Source: GoogleChrome/workbox

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.

workbox-cacheable-response

Most helpful comment

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

>All comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Fillah picture Fillah  路  3Comments

josephliccini picture josephliccini  路  4Comments

Sturgelose picture Sturgelose  路  3Comments

piehei picture piehei  路  4Comments

nevaan9 picture nevaan9  路  4Comments