GoogleChromeLabs / sw-appcache-behavior

A service worker implementation of the behavior defined in a page's AppCache manifest.
Apache License 2.0
54 stars 15 forks source link

Remove hash part of URL from request URL and client URL #17

Closed arneschuldt closed 4 years ago

arneschuldt commented 4 years ago

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 https://github.com/GoogleChrome/workbox/issues/488 and https://github.com/GoogleChromeLabs/sw-precache/issues/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.

googlebot commented 4 years ago

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

:memo: Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

arneschuldt commented 4 years ago

@googlebot I signed it!

googlebot commented 4 years ago

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

jeffposnick commented 4 years ago

This is now in the v0.3.0 release.

arneschuldt commented 4 years ago

Thank you very much!