Posts

Showing posts with the label Browser Cache

Cache Busting Index.html In A .Net Core Angular 5 Website

Answer : Here's what I ended up with after combining a bunch of answers. My goal was to never cache index.html. While I was in there, and since Angular nicely cache-busts the js and css files, I had it cache all other assets for a year. Just make sure you're using a cache-busting mechanism for assets, like images, that you're managing outside of Angular. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { // ... app.UseStaticFiles(); if (env.IsDevelopment()) { // no caching app.UseSpaStaticFiles(); } else { app.UseSpaStaticFiles(new StaticFileOptions { OnPrepareResponse = context => { context.Context.Response.Headers.Add("Cache-Control", "max-age=31536000"); context.Context.Response.Headers.Add("Expires", "31536000"); } }); } // ... app.UseSpa(spa => { spa.Options.DefaultPageStaticFileOptions = new StaticFileOptions ...

Chrome - Disable Cache For Localhost Only?

Image
Answer : You can certainly prevent all your file from hitting the cache, but this is an all-or-nothing setting. You can't decide which files get cleared from the cache and which files stay in the cache. During development, since you are using Chrome, I'd recommend to enable the setting for "Disable cache (while DevTools is open)": If you are like me, cache will be disabled every time you have the DevTools panel opened. Another thing you can do is to instruct your server to bypass cache altogether for all your resources. Since jQuery is coming from a CDN, this no-cache setting won't apply for it. To disable cache for resources you can include the following response header: Cache-Control:no-cache, no-store In the browser, use this to refresh the page: Ctrl + Shift + R this will ignore the cache (whereas Ctrl+r will use the cache). yw :) If you are using Apache you can disable cache on your server (localhost) by placing .htaccess file into your htd...