Is outputHashing useful in Angular with PWA enabled?

300 Views Asked by At

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.

1

There are 1 best solutions below

2
On

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.