Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Random Blazor "Failed to find a valid digest in the 'integrity' attribute for resource" on iis

I am facing an issue when loading a site built and published using blazor. I get the following error message:

" Failed to find a valid digest in the 'integrity' attribute for resource 'https://MYWEBSITEURL.com/_framework/System.Private.CoreLib.dll' with computed SHA-256 integrity 'xV9SflNt5Ex5gP7OznQorlp2VkdJXkcAiopU+h5DRzY='. The resource has been blocked. "

I assume that the browser blocks the files from downloading because the hashes created when publishing do not match.

No files where edited after publish and no git was involved I publish the application from VS 2019 and upload to the server via FTP.

However, the pattern is random. If I refresh the page a few times, it works, and if I refresh the page again, it breaks again. Some times one resource gest blocked, other times none, and other times 10.

Any assistance would be greatly appreciated.

like image 846
S.Michaelides Avatar asked Oct 22 '25 08:10

S.Michaelides


1 Answers

I have the same problem and looks like the root cause is that service-worker-assets.js with OLD hashed values is cached by the browser (at least I see in dev tools on Network tab that when new version of SW tries to download new service-worker-assets.js file it retrieved from disc cache).

See github issue with potential solution posted by @dvallmen (I've not tested yet on production)

github.com/dotnet/aspnetcore/issues/39016

Solution is to disable retrieving service-worker-assets.js from HTTP cache by registering SW with updateViaCache parameter set to 'none'

navigator.serviceWorker.register('/service-worker.js', {updateViaCache: 'none'})
like image 85
user3529134 Avatar answered Oct 25 '25 03:10

user3529134