2

Output-hashing in Angular prevents version inconsistencies between parts of the application when browser or proxy cache is active.

With PWA, same is achieved with Service-Worker and ngsw.json which is also based on hashes.

Are there any scenarios where outputHashing=all can still be useful with PWA enabled? Are there any downsides of keeping it turned on?

IE is out of scope.

Vilmantas Baranauskas
  • 6,596
  • 3
  • 38
  • 50

1 Answers1

1

If you consider deploying your static files to a file storage somewhere and you have output hashing enabled, your files will be named something like main.23kj4h32kj4h3423.js instead of just main.js. After deploying a new version to that storage, you'll have some cleaning up to do because main.xxx.js just got a new file name.

On the other hand, if you have a really large app and uploading all files to that same storage takes a while, you need to consider the scenario where a user visits your site somewhere in the middle of the upload process. Let's say you don't have output hashing enabled, the visitor might get some old and some new files.

Emiel Koning
  • 4,039
  • 1
  • 16
  • 18
  • In case of slow upload, I don't see how output hashing could improve anything: When disabled, PWA would probably report VERSION_INSTALLATION_FAILED due to mismatching hashes within PWA descriptor, when enabled PWA would probably report the same due to some missing files. – Vilmantas Baranauskas Oct 27 '22 at 05:53
  • I was thinking of enabling hashing, uploading all files and making sure you update `index.html` and `ngsw.json` last. I think that should keep downtime to a minimum and prevent PWA going into error state. – Emiel Koning Oct 27 '22 at 10:27