-2

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 ?

benshabatnoam
  • 7,161
  • 1
  • 31
  • 52
  • Do you mean after deploying the app? – benshabatnoam Jan 01 '19 at 14:19
  • Yes, we use yarn, gulp. Before deploying the app, we use ng build --prod plugins. It creates a hash files for resources. And the browser should be force to load new minimized resource files. But we face with template-cache problem and we have to delete browser cache to run it properly. This is really big problem for our users, can you give me some advice? What else can I do? – Mustafa Akgure Jan 02 '19 at 10:43

2 Answers2

0

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

benshabatnoam
  • 7,161
  • 1
  • 31
  • 52
0

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.