nimiq / hub

The Nimiq Hub provides a unified interface for all Nimiq accounts, addresses, and contracts.
https://nimiq.github.io/hub
31 stars 11 forks source link

Temporarily circumvent Desktop Safari resource integrity check bug client-side #453

Closed curdbecker closed 3 years ago

curdbecker commented 3 years ago

ServiceWorker.js: drop all headers from request that could trigger a HTTP 304 response

This commit contains a temporary workaround to deal with a bug in Desktop Safari that prevents a successful resource integrity check when a resource is loaded via the service worker and the webpage forces cache revalidation (like we do).

When the resource is not modified, the server responds with a HTTP "304 - Not modified" response. However, then Safari (supposedly) tries to check the content from this response against the integrity hash instead of the actual cached content. Obviously, this is pointless, since a HTTP 304 doesn't contain any content, because that would defer the entire point, right? Hence, the integrity check won't ever succeed.. :-/

Therefore, we're now removing all headers from the request that could trigger such a response. Addmitedly, that's less then ideal, since it effectiviely breaks caching for all resources with an integrity check. However, these resources are typically small and this patch is intended to be temporary.

curdbecker commented 3 years ago

I've just tested it again and it works as intended. Ready to be deployed :)