1

I have been developing many updates for my website, but many clients are complaining that they didn't get any updates. When i asked them to clear the browser cache, their problem is solved. But its difficult for clients with below average computer literacy to clear cache. So is there any way to detect cached data in browsers and reload cache if there's change in my site contents? I had developed my site on HTML,Angular JS.

jijishthomas
  • 41
  • 1
  • 10

2 Answers2

1

you can use some extensions with your js, css files callings like

<header>
 <link href="MyFolder/my.css?v=1.5">
 <script src="myFolder/my.js?v=1.5">
</header>

v = version you can use a global variable to hold value of version then you can increase version number with your updates

Azad
  • 4,593
  • 3
  • 25
  • 52
1

Simply add cache busting.

Add timestamp

"?ts=" + new Date().getTime()

or As in your case, for build deployment its better to use version. Fetch your version number from config file

var ver = "?ver=" + config.version;
then you url look like
app.js + ver => app.js?ver=1.0.1

For version number in config you may keep it on client side config or get it from api on first hit and save it.

If you are using requirejs then its so simple just add value like this:

require.config({ urlArgs: ver});

It will automatically append it in every Js url.