Search code examples
angularjshtmlcachingcache-control

Cache-busting for html


Ive read about this method called cache-busting that allows us to add version parameters to our js and css files so that clients wont have to clear cache every time we have an update. However, I didn`t read any about html.

Is there any method that allows us to load latest html file changes without clearing the cache?

P.S. I dont know about others but I just discovered that it is angularjs that is caching my templates. I posted my own solution anyway


Solution

  • Solved it. Just append a parameter string to your routes that are referencing your html files just like what we did on cache-busting for css and js.

    .when('/login', {
            templateUrl: "../views/login.html?v=" + versionNumber,
            controller: "LoginController"
        })
    

    Where 'versionNumber' is a global variable.