I developed a web application in asp.net mvc 4 where I'm serving some resource files like css, js, images etc. And to always server an updated file, i appended a random string into query string. That query string value changes when I publish my application. So each publish activity changes that string. But browser does not downloads the files even with changed URL. Browser downloads the file first time and always serves from cached copy. Below is my code.
<script src="~/Content/js/userdefined/dashboard.js?t=@Constants.RandomString" defer></script>
public static class Constants
{
public static readonly string RandomString = Guid.NewGuid().ToString().ToLower();
}
So each time application gets published, it generates a new string which is working as expected.
Can anyone help in this like why browser is not downloading updated file even when url gets changed?
Aucun commentaire:
Enregistrer un commentaire