Remove hash part of URL from request URL and client URL #17
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Fragment identifiers (the hash part of the URL) are also part of the service worker request URL. This causes problems when using the
sw-appcache-behavior
AppCache polyfill with Single-Page Applications (SPA) because the URL including the fragment identifier does not match the URL cached from the manifest.Related
The same problem had already been identified in GoogleChrome/workbox#488 and GoogleChromeLabs/sw-precache#290.
Solution
This pull request proposes a solution that seems to solve the problem in practical tests.
Tests
The
sw-appcache-behavior
project already contains automated tests. However, they focus on the tricky part of populating the cache correctly from the manifest. There are currently no existing tests that check whether data is correctly retrieved back from the cache by the service worker.Hence, we were not able to simply derive a test for the new behaviour proposed in the pull request.
Hopefully, the pull request can still help improve the
sw-appcache-behavior
.