I tried this Middleware but the browser still saving files.
I want user will always get the last version of js and css files.
public void Configure(IApplicationBuilder app) { app.UseSession(); app.UseDefaultFiles(); app.UseStaticFiles(new StaticFileOptions { OnPrepareResponse = context => context.Context.Response.Headers.Add("Cache-Control", "no-cache") }); }
Just use the Cache-Control: no-cache header. Implement it as delegating-Handler and make sure your header is applied (with MS Owin Implementation hook up on OnSendingHeaders() .
In the root web. config we specify that we don't want to the index. html to cache by setting the cache-control , Pragma and Expires request headers as well as the max-age to 0.
Disabling browser cache in ASP.NET core:
public class HomeController : Controller { [ResponseCache(NoStore =true, Location =ResponseCacheLocation.None)] public IActionResult Index() { return View(); } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With