3

When I am ready to publish my code changes to our server, I build and compile using Angular AOT and copy my files over. Sometimes end users aren't getting these changes and have to do a hard refresh, or go into their browser history and clear cached images and files. What is the recommended method of forcing a hard refresh when I make changes to code on the server?

I've read about appending a version number to .css and .js files so the browser re-downloads the newly named files, but with angular AOT creating ngfactory.js files and ngfactory.js.map files, etc, I want to make sure I am doing this properly.

Also, I am hosting the site using IIS so if there is a way to achieve refreshing through ISS I am open to that as well.

Kevin Quiring
  • 639
  • 1
  • 11
  • 26

2 Answers2

0

When you build using ng build --prod which implies aot as well, the generated bundles have new names..

A common approach is to configure IIS to never allow caching of index.html.. That way, if clients see the same bundle name, in the always current index.html, its cached.. But if you generate a new bundle, its downloaded.

Related SO answer here.

Also, you can google 'Cache Busting" to find a lot of resources.

ttugates
  • 5,818
  • 3
  • 44
  • 54
0

For that u can set iis not to cache index.html file. for that you have to simply include web.config file and add this settings in to it.

<configuration>

  <location path="index.html">
    <system.webServer>
      <httpProtocol>
        <customHeaders>
          <add name="Cache-Control" value="no-cache" />
        </customHeaders>
      </httpProtocol>
    </system.webServer>
  </location>

</configuration>
CodeMind
  • 616
  • 1
  • 7
  • 19