Go to file
Maximilian Koeller ee35e223a7 feat(service-worker): use `ignoreVary: true` when retrieving responses from cache (#34663)
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 previously not
possible.

Fixes #36638

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.

PR Close #34663
2020-05-01 09:44:07 -07:00
.circleci build: migrate from gulp to ng-dev for running formatting (#36726) 2020-04-24 12:32:18 -07:00
.devcontainer
.github
.vscode
.yarn build: update to latest version of yarn (#36464) 2020-04-14 12:47:30 -07:00
aio feat(service-worker): include `CacheQueryOptions` options in ngsw-config (#34663) 2020-05-01 09:44:07 -07:00
dev-infra feat(dev-infra): create format tool in @angular/dev-infra-private (#36726) 2020-04-24 12:32:18 -07:00
docs
goldens feat(service-worker): include `CacheQueryOptions` options in ngsw-config (#34663) 2020-05-01 09:44:07 -07:00
integration ci: migrate payload size tracking goldens to the golden directory (#36455) 2020-04-24 09:05:11 -07:00
modules revert: "feat(dev-infra): exposed new rule 'component_benchmark' via dev_infra (#36434)" (#36798) 2020-04-24 11:03:38 -07:00
packages feat(service-worker): use `ignoreVary: true` when retrieving responses from cache (#34663) 2020-05-01 09:44:07 -07:00
scripts build: use sh instead of exec for release scripts (#36862) 2020-04-29 13:04:43 -07:00
third_party
tools ci: fix bad reference to `head` property in rebase-pr script (#36825) 2020-04-28 09:13:35 -07:00
.bazelignore
.bazelrc
.bazelversion
.clang-format
.dev-infra.json build: migrate from gulp to ng-dev for running formatting (#36726) 2020-04-24 12:32:18 -07:00
.editorconfig
.gitattributes
.gitignore
.mailmap
.nvmrc
.pullapprove.yml revert: "feat(dev-infra): exposed new rule 'component_benchmark' via dev_infra (#36434)" (#36798) 2020-04-24 11:03:38 -07:00
.yarnrc build: update to latest version of yarn (#36464) 2020-04-14 12:47:30 -07:00
BUILD.bazel revert: "feat(dev-infra): exposed new rule 'component_benchmark' via dev_infra (#36434)" (#36798) 2020-04-24 11:03:38 -07:00
CHANGELOG.md release: cut the v10.0.0-next.4 release 2020-04-29 14:07:45 -07:00
CODE_OF_CONDUCT.md
CONTRIBUTING.md
LICENSE
README.md
WORKSPACE revert: "feat(dev-infra): exposed new rule 'component_benchmark' via dev_infra (#36434)" (#36798) 2020-04-24 11:03:38 -07:00
browser-providers.conf.js
gulpfile.js build: migrate from gulp to ng-dev for running formatting (#36726) 2020-04-24 12:32:18 -07:00
karma-js.conf.js
package.json release: cut the v10.0.0-next.4 release 2020-04-29 14:07:45 -07:00
protractor-perf.conf.js revert: "feat(dev-infra): exposed new rule 'component_benchmark' via dev_infra (#36434)" (#36798) 2020-04-24 11:03:38 -07:00
shims_for_IE.js
test-events.js
test-main.js
tslint.json
yarn.lock build: migrate from gulp to ng-dev for running formatting (#36726) 2020-04-24 12:32:18 -07:00
yarn.lock.readme.md

README.md

CircleCI Join the chat at https://gitter.im/angular/angular npm version

Angular

Angular is a development platform for building mobile and desktop web applications using TypeScript/JavaScript and other languages.

Quickstart

Get started in 5 minutes.

Changelog

Learn about the latest improvements.

Want to help?

Want to file a bug, contribute some code, or improve documentation? Excellent! Read up on our guidelines for contributing and then check out one of our issues in the hotlist: community-help.