i use angular-template-cache. follow code exist for remove template cache in app module but i need to remove all templateCache with gulp on dev machine.
myApp.run(function($rootScope, $templateCache) {
$rootScope.$on('$viewContentLoaded', function() {
$templateCache.removeAll();
});
});
The best way to avoid template caching is revisioning your files.
Since you are using
gulp
, you can revision your files usinggulp-rev
orgulp-rev-all
.What is revisioning?
Static asset revisioning by appending content hash to filenames
unicorn.css
→unicorn-d41d8cd98f.css
.i.e., On every builds the filename changes and that way avoiding template caching. You can revision every file including
.html
,.css
,.js
,images
,videos
etc.Since
gulp-rev-all
is the latest and forked fromgulp-rev
, let's talk aboutgulp-rev-all
only.Revisioning using
gulp-rev-all
:if you want to neglect some files from revisioning, you can do that like this.
Consider all your files are in the folder
dist
and save the new revisioned files in the folderwww
.(You can save them indist
also. Consideringwww
is your build directory.)Next, create a
manifest
file to map your files with the revisioned one. for that use.manifestFile()
function. which returns a transform function that will filter out any existing files going through the pipe and will emit a new manifest file. Must be called after .revision().An asset manifest, mapping the original paths to the revisioned paths, will be written to
www/manifest/rev-manifest.json
:Complete code:
Read more about
gulp-rev-all
here