We have template cache problem for html files and we would like to solve it without deleting the cache data(If we delete it, we see performance issue). Do you have any suggestions for it ?
Angular 6 template cache problem (for html files) on gulp build
634 Views Asked by Mustafa Akgure At
2
There are 2 best solutions below
0
On
One good solution for your problem is called file revision or Hashing, this approach concept is:
simply rename every html/js/img file served by our app by concatenating a random-hash before the file extension
There are many possible ways doing that. One good way is this 3 steps:
Step 1. Creating revision:rename gulp task
gulp.task(“revision:rename”, [“compile”], () =>
gulp.src(["dist/**/*.html",
"dist/**/*.css",
"dist/**/*.js",
"dist/**/*.{jpg,png,jpeg,gif,svg}"])
.pipe(rev())
.pipe(revdel())
.pipe(gulp.dest(“dist”))
.pipe(rev.manifest({ path: “manifest.json” }))
.pipe(gulp.dest(“dist”))
);
Step 2. Creating revision:updateReferences gulp task
gulp.task(“revision:updateReferences”, [“compile”, “revision:rename”], () =>
gulp.src([“dist/manifest.json”,”dist/**/*.{html,json,css,js}”])
.pipe(collect())
.pipe(gulp.dest(“dist”))
);
Step 3. Creating compile:production gulp task
gulp.task(“compile:production”, [“compile”, “revision:rename”, “revision:updateReferences”]);
This 3 steps solution taken from:
medium.com - Solving Browser Cache Hell With Gulp-Rev - By Felipe Bernardes
Thanks for your answer, but our solution is little different. In our company, we use weblogic server and When we deploy the app, it creates all resources in specific folder and again and again(It holds previous ones). After deleting the unnecessary resources, the app start to work properly.