Help with SRI "Failed to find a valid digest in the 'integrity' attribute"

Our application is self-hosted on nginx. After releasing a new version of our app, (which is just removing all the old assets from the server, and replacing them with new ones that were the result of an ember build --environment=production)

We are getting the following error message when reloading the application (in chrome):

Failed to find a valid digest in the 'integrity' attribute for resource '<hosted_endpoint>' with computed SHA-256 integrity '<integrity_hash>'. The resource has been blocked.

My guess it has something to do with the caching of static assets by ember-service-worker and by extension ember-service-worker-asset-cache, where the index.html is already in the browser cache. On a page refresh of our app, the integrity hash in the cached index.html no longer exists on the server, because of the new release, and the loading of the app crashes.

As far as I understand SRI is used to make sure the correct assets are loaded when serving assets from a CDN. In this case, I am not using a CDN.

As far as I understand, the service worker is correctly configured with a versionStrategy: "every-build".

The only option I see right now is disabling ember-cli-sri, but that seems like a bad idea. Disabling ember-service-worker is no option.

I was hoping someone might have another idea.

IIRC you should never cache index.html in a single page application for exactly this reason. So I think what you want to do is just add no cache headers to the index request in your nginx config. I’ve not used nginx in prod before but I imagine an article like this covers roughly what you want.

1 Like

I think your answer led me to the correct solution.

It was index.html caching, by the service worker. Disabled that, and it seems correct now.

Time will tell if the issue does not pop up again.

1 Like