Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clearing Browser Cache when deploy a new release

I've a ASP.Net MVC + angular web application. And about 500 + users are using the application.

The problem is whenever we do a new publish/ release we have to say the users to clear their browser cache. This is annoying for the users.

How other websites such as facebook etc.. manage the browser cache when they update their application/site since we don't clear our browser cache too often.

Is there any way to automatically clear borwser cache when there is a new release.

like image 420
tarzanbappa Avatar asked Nov 06 '17 11:11

tarzanbappa


1 Answers

With ASP.Net Core MVC you can use the asp-append-version TagHelper for your script files. It calculates a hash of the file and appends it to the filename:

<link rel="stylesheet" type="text/css" href="myfile.css" asp-append-version="true" />    
<script src="myfile.js" asp-append-version="true"></script>

so the files would become something like this:

<link rel=stylesheet href="myfile.css?v=qWYa_XOt9FCnEt2z8CjC7apiyjA5l9UA9UCqT028LI">
<script src="myfile.js?v=eN9kwxdWtX5aP8H3TFVOQrwu08Qndyktg5kvpSLa1A">
like image 178
Riv Avatar answered Oct 20 '22 18:10

Riv