1

We have an Angular 13 app served on Nginx. Usually, when we deploy new changes, we don't seem them until we do a hard refresh on the page, clearing the cache.

I've seen this issue in a few questions around, but none of the solutions worked so far:

We are using the build command

ng build --prod --aot --output-hashing=all

And angular.json is configured with

"outputHashing": "all",

in dev and production.

I've tried HTML meta tags:

<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">

I've searched about more general issues and configurations about cache:

Or could this be caused by a cache config in Nginx? I've looked at A Guide to Caching with NGINX and NGINX Plus, but I'm not very familiarised with Nginx.

  • do you see different hash between deployments? – Jimmy Nov 27 '22 at 21:26
  • Where do I see the hash? Is it [this](https://medium.com/@dao.houssene/angular-the-hash-trap-b2d415c2c241) hash that should be enabled? – Ludovic Beghin Nov 28 '22 at 14:53
  • the number in the filename is what I refer as hash, something like main-8765.js. If the file name is different, browser will pick it up automatically – Jimmy Nov 28 '22 at 17:26
  • Most of the filenames (including several main.number.js) remain the same, but after a new deploy there is indeed a new hashed main.number.js – Ludovic Beghin Nov 28 '22 at 19:05
  • 1
    the hash has to change for browsers to update, so make sure you get the new number first, for some more info, you could check this: https://jakearchibald.com/2016/caching-best-practices/ – Jimmy Nov 28 '22 at 19:13

0 Answers0