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
Service worker cache.match options #28443
Comments
I have a similar scenario which warrants for adding especially I have verified that having the self.addEventListener('fetch', event => {
// with this option everything works like a charm
const options = {
ignoreVary: true
};
event.respondWith(
caches.match(event.request, options)
.then(response => {
if (response) {
return response;
}
return fetch(event.request);
})
);
}); At the moment I can't get my PWA to work using |
As were are facing a similiar issue in my project I would like to provide a pull request. interface AssetGroup {
name: string;
installMode?: 'prefetch' | 'lazy';
...
cacheMatchOptions?: ClientMatchOptions;
...
}
export interface DataGroup {
name: string;
...
cacheMatchOptions?: ClientMatchOptions,
cacheConfig: {
...
};
}
// from DOM lib...
export interface ClientMatchOptions {
ignoreMethod?: boolean;
ignoreSearch?: boolean;
ignoreVary?: boolean;
} Since the ngsw always creates new requests for fetching resources without copying the original headers I would also suggest to provide default ClientMatchOptions = |
@spike-rabbit, your recommendation sounds reasonable (from a super quick look). Feel free to create a PR and we can discuss the details there. |
Previously it was impossible to provide options for Cache#match. As it is sometimes necessary to override the default behavior the Cache#match options can now be configured for assets and data groups. closes angular#28443
Previously it was impossible to provide options for Cache#match. As it is sometimes necessary to override the default behavior the Cache#match options can now be configured for assets and data groups. closes angular#28443
Previously it was impossible to provide options for Cache#match. As it is sometimes necessary to override the default behavior the Cache#match options can now be configured for assets and data groups. closes angular#28443
Previously it was impossible to provide options for Cache#match. As it is sometimes necessary to override the default behavior the Cache#match options can now be configured for assets and data groups. closes angular#28443
Previously it was impossible to provide options for Cache#match. As it is sometimes necessary to override the default behavior the Cache#match options can now be configured for assets and data groups. closes angular#28443
Previously it was impossible to provide options for Cache#match. As it is sometimes necessary to override the default behavior the Cache#match options can now be configured for assets and data groups. closes angular#28443
Previously it was impossible to provide options for Cache#match. As it is sometimes necessary to override the default behavior the Cache#match options can now be configured for assets and data groups. closes angular#28443
Previously it was impossible to provide options for Cache#match. As it is sometimes necessary to override the default behavior the Cache#match options can now be configured for assets and data groups. closes angular#28443
Previously it was impossible to provide options for Cache#match. As it is sometimes necessary to override the default behavior the Cache#match options can now be configured for assets and data groups. closes angular#28443
Previously it was impossible to provide options for Cache#match. As it is sometimes necessary to override the default behavior the Cache#match options can now be configured for assets and data groups. closes angular#28443
Previously it was impossible to provide options for Cache#match. As it is sometimes necessary to override the default behavior the Cache#match options can now be configured for assets and data groups. closes angular#28443
…s from cache The Angular ServiceWorker always uses a copy of the request without headers for caching assets (in order to avoid issues with opaque responses). Therefore, it was previously not possible to retrieve resources from the cache if the response contained [Vary](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Vary) headers. In addition to that, `Vary` headers do not work in all browsers (or work differently) and may not work as intended with ServiceWorker caches. See [this article](https://www.smashingmagazine.com/2017/11/understanding-vary-header) and the linked resources for more info. This commit avoids the aforementioned issues by making sure the Angular ServiceWorker always sets the `ignoreVary` option passed to [Cache#match()](https://developer.mozilla.org/en-US/docs/Web/API/Cache/match) to `true`. This allows the ServiceWorker to correctly retrieve cached responses with `Vary` headers, which was previosuly not possible. BREAKING CHANGE: Previously, [Vary](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Vary) headers would be taken into account when retrieving resources from the cache, completely preventing the retrieval of cached assets (due to ServiceWorker implementation details) and leading to unpredictable behavior due to inconsistent/buggy implementations in different browsers. Now, `Vary` headers are ignored when retrieving resources from the ServiceWorker caches, which can result in resources being retrieved even when their headers are different. If your application needs to differentiate its responses based on request headers, please make sure the Angular ServiceWorker is [configured](https://angular.io/guide/service-worker-config) to avoid caching the affected resources. Closes angular#28443 Fixes angular#36638
…s from cache The Angular ServiceWorker always uses a copy of the request without headers for caching assets (in order to avoid issues with opaque responses). Therefore, it was previously not possible to retrieve resources from the cache if the response contained [Vary](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Vary) headers. In addition to that, `Vary` headers do not work in all browsers (or work differently) and may not work as intended with ServiceWorker caches. See [this article](https://www.smashingmagazine.com/2017/11/understanding-vary-header) and the linked resources for more info. This commit avoids the aforementioned issues by making sure the Angular ServiceWorker always sets the `ignoreVary` option passed to [Cache#match()](https://developer.mozilla.org/en-US/docs/Web/API/Cache/match) to `true`. This allows the ServiceWorker to correctly retrieve cached responses with `Vary` headers, which was previosuly not possible. BREAKING CHANGE: Previously, [Vary](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Vary) headers would be taken into account when retrieving resources from the cache, completely preventing the retrieval of cached assets (due to ServiceWorker implementation details) and leading to unpredictable behavior due to inconsistent/buggy implementations in different browsers. Now, `Vary` headers are ignored when retrieving resources from the ServiceWorker caches, which can result in resources being retrieved even when their headers are different. If your application needs to differentiate its responses based on request headers, please make sure the Angular ServiceWorker is [configured](https://angular.io/guide/service-worker-config) to avoid caching the affected resources. Closes angular#28443 Fixes angular#36638
…s from cache The Angular ServiceWorker always uses a copy of the request without headers for caching assets (in order to avoid issues with opaque responses). Therefore, it was previously not possible to retrieve resources from the cache if the response contained [Vary](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Vary) headers. In addition to that, `Vary` headers do not work in all browsers (or work differently) and may not work as intended with ServiceWorker caches. See [this article](https://www.smashingmagazine.com/2017/11/understanding-vary-header) and the linked resources for more info. This commit avoids the aforementioned issues by making sure the Angular ServiceWorker always sets the `ignoreVary` option passed to [Cache#match()](https://developer.mozilla.org/en-US/docs/Web/API/Cache/match) to `true`. This allows the ServiceWorker to correctly retrieve cached responses with `Vary` headers, which was previosuly not possible. BREAKING CHANGE: Previously, [Vary](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Vary) headers would be taken into account when retrieving resources from the cache, completely preventing the retrieval of cached assets (due to ServiceWorker implementation details) and leading to unpredictable behavior due to inconsistent/buggy implementations in different browsers. Now, `Vary` headers are ignored when retrieving resources from the ServiceWorker caches, which can result in resources being retrieved even when their headers are different. If your application needs to differentiate its responses based on request headers, please make sure the Angular ServiceWorker is [configured](https://angular.io/guide/service-worker-config) to avoid caching the affected resources. Closes angular#28443 Fixes angular#36638
Previously it was not possible to provide `CacheQueryOptions` ([MDN](https://developer.mozilla.org/en-US/docs/Web/API/Cache)) for querying the Cache. This commit introduces a new parameter called `cacheQueryOptions` for `DataGroup` and `AssetGroup`. Currently only `ignoreSearch` is supported as `ignoreVary` and `ignoreMethod` would require using the complete Request object for matching which is not possible with the current implementation. Although it is not documented and will not work it is technical possible provide values for `ignoreVary` and `ignoreMethod` as well. Closes angular#28443
Previously it was not possible to provide `CacheQueryOptions` ([MDN](https://developer.mozilla.org/en-US/docs/Web/API/Cache)) for querying the Cache. This commit introduces a new parameter called `cacheQueryOptions` for `DataGroup` and `AssetGroup`. Currently only `ignoreSearch` is supported as `ignoreVary` and `ignoreMethod` would require using the complete Request object for matching which is not possible with the current implementation. Although it is not documented and will not work it is technical possible provide values for `ignoreVary` and `ignoreMethod` as well. Closes angular#28443
Previously it was not possible to provide `CacheQueryOptions` ([MDN](https://developer.mozilla.org/en-US/docs/Web/API/Cache)) for querying the Cache. This commit introduces a new parameter called `cacheQueryOptions` for `DataGroup` and `AssetGroup`. Currently only `ignoreSearch` is supported as `ignoreVary` and `ignoreMethod` would require using the complete Request object for matching which is not possible with the current implementation. Although it is not documented and will not work it is technical possible provide values for `ignoreVary` and `ignoreMethod` as well. Closes angular#28443
Previously it was not possible to provide `CacheQueryOptions` ([MDN](https://developer.mozilla.org/en-US/docs/Web/API/Cache)) for querying the Cache. This commit introduces a new parameter called `cacheQueryOptions` for `DataGroup` and `AssetGroup`. Currently only `ignoreSearch` is supported as `ignoreVary` and `ignoreMethod` would require using the complete Request object for matching which is not possible with the current implementation. Although it is not documented and will not work it is technical possible provide values for `ignoreVary` and `ignoreMethod` as well. Closes angular#28443
Previously it was not possible to provide `CacheQueryOptions` ([MDN](https://developer.mozilla.org/en-US/docs/Web/API/Cache)) for querying the Cache. This commit introduces a new parameter called `cacheQueryOptions` for `DataGroup` and `AssetGroup`. Currently only `ignoreSearch` is supported as `ignoreVary` and `ignoreMethod` would require using the complete Request object for matching which is not possible with the current implementation. Closes angular#28443
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
…fig (angular#34663) Previously it was not possible to provide `CacheQueryOptions` ([MDN](https://developer.mozilla.org/en-US/docs/Web/API/Cache)) for querying the Cache. This commit introduces a new parameter called `cacheQueryOptions` for `DataGroup` and `AssetGroup`. Currently only `ignoreSearch` is supported as `ignoreVary` and `ignoreMethod` would require using the complete Request object for matching which is not possible with the current implementation. Closes angular#28443 PR Close angular#34663
🚀 feature request
Relevant Package
@angular/service-worker
@angular/pwa
Description
At the moment there is no support for cache.match options in listed above package. I have a scenario with images which have some dynamic hashes as url parameters.
Desired behaviour
The same image
to be cached as
Describe the solution you'd like
It's good to have possibility to specify some properties in ngsw-config.json assetGroup like
The text was updated successfully, but these errors were encountered: