Stylesheets cached on Azure

Posted on Jan 17, 2015 by Morten Empeño

A simple solution to avoid stylesheets being cached.

Background

This weekend I was developing an MVC website, and publishing it to Azure.

Everything went well, until I dared making a small change to an existing stylesheet. 

The small change was easy to spot on my local environment, but I could not make the change take effect on the production environment. After a lot of Googling and desperate attempts to deploy to Azure in different ways, I found that the issue proved to be the good old friend: Caching.

Solution

I decided to introduce version named stylesheets. My small style change was to be found in s stylesheet named: bootstrap.css

I renamed the stylesheet to bootstrap1_0.css and made the necessary changes in my BundleConfig file:

bundles.Add(new StyleBundle("~/Content/css").Include(
                      "~/Content/bootstrapv1_0.css",
                      "~/Content/site.css"));

I deployed once again, and the change was effectful.

Back to List