1

I have an angular2 web app. Every time I make changes to it, I deploy it on a dev server using cPanel.

I build the app using ng build --env=prod and then copy the contents of the dist folder.

However, when I access the site, it always loads the old version. I have to clear my cache, only then does it load the latest version.

How can I fix this, so that, the latest version is loaded (but, if there is no change, then the cached copy can be loaded)?

mridula
  • 3,203
  • 3
  • 32
  • 55
  • Cache can be persisted at many locations (server, network, and browser). You have to figure which location(s) has the cached copy and then figure out how to clear it based on that. You also did not mention where you clear your cache from. – Igor Mar 11 '17 at 11:49
  • 1
    Use --prod. Not just --env=prod. That will use AOT, minify your bundles, and generate unique bundle names. – JB Nizet Mar 11 '17 at 11:49
  • 4
    @Aravind So, you would be happy if, every time you would go to an some web site, you saw the version of the site from 2002 instead of the newest version? How is that a useless question? – JB Nizet Mar 11 '17 at 12:06
  • @Igor - I am clearing the browser cache, after which it loads the latest version. – mridula Mar 11 '17 at 15:14
  • @JB Nizet - Thanks! I will do that. – mridula Mar 11 '17 at 15:15
  • Have you seen this answer yet? http://stackoverflow.com/a/36585119/1260204 – Igor Mar 11 '17 at 15:16
  • @Aravind - Of course I don't want to NOT cache it. But if there is a new version, I would definitely want it to load the latest. So I disagree with you. – mridula Mar 11 '17 at 15:16

0 Answers0