PWA software update (Angulars swUpdate) - Hash mismatch!

Hello,

I implemented Angular swUpdate for automatic detection and installation of new versions of my PWA (Angular checking for updates). Here is the output of my app flow. After uploading all files of the www-directory (ionic build --prod) swUpdate detects a new version, but it recognizes a hash mismatch for the file combined.js after “cache busting”

2023-12-13 12:00:25 info: WebWorkerService initialize() evt type:  ["VERSION_DETECTED"]
2023-12-13 12:00:25 info: WebWorkerService Downloading new app version: b78a9060ba37a0038dace631b0ad1f7a8bcb848b 
2023-12-13 12:00:27 info: WebWorkerService initialize() evt type:  ["VERSION_INSTALLATION_FAILED"]
2023-12-13 12:00:27 info: WebWorkerService Failed to install app version 'b78a9060ba37a0038dace631b0ad1f7a8bcb848b': Hash mismatch (cacheBustedFetchFromNetwork): https://<mytestdomain>/combined-sw.js: expected 94ee71dff0bdb40066dfd2f27870a117b4cf6ef5, got 6b6d9a707ed3914a7ee51e349d06dbda64079ebf (after cache busting)
Error: Hash mismatch (cacheBustedFetchFromNetwork): https://<mytestdomain>/combined-sw.js: expected 94ee71dff0bdb40066dfd2f27870a117b4cf6ef5, got 6b6d9a707ed3914a7ee51e349d06dbda64079ebf (after cache busting)
    at PrefetchAssetGroup.cacheBustedFetchFromNetwork (https://<mytestdomain>/ngsw-worker.js:479:21)
    at async PrefetchAssetGroup.fetchFromNetwork (https://<mytestdomain>/ngsw-worker.js:454:19)
    at async PrefetchAssetGroup.fetchAndCacheOnce (https://<mytestdomain>/ngsw-worker.js:433:21)
    at async https://<mytestdomain>/ngsw-worker.js:538:9

The file ngsw.json lists all files with the corresponding hashes, e.g. for combined.js

   [...]
    "/combined-sw.js": "94ee71dff0bdb40066dfd2f27870a117b4cf6ef5",
   [...]

Does anyone have an explanation as to why a different hash value is determined during installation than the one specified in the file?

If my question is not correct in this section, please let me know where my question would be better placed.

Hi, I hadn’t thought about the fact that the newline type is also part of the content of a file and is taken into account by the hash. I work under Windows, new files I created under vscode contained CRLFs. However, when transferring them to my Linux server, the CRLFs are converted to LFs. This meant that the files concerned were not identical. Fortunately, you can easily change the newline type in VS Code. Now an app update works without any problems.