How can I force browsers to reload cached css files when using asp net themes


When using ASP.NET themes, it is common for browsers to cache CSS , which can cause issues when you make to your stylesheets. In this article, we will explore different methods to force browsers to reload cached CSS files when using ASP.NET themes.

Method 1: Adding a Version Number to CSS File

One way to ensure that browsers reload cached CSS files is by adding a version number to the file name. By changing the version number, the will treat it as a new file and fetch it from the server.

In the above example, we have added “?v=1” to the CSS file URL. Whenever you make changes to the CSS file, you can increment the version number to force the browser to fetch the updated file.

Method 2: Using Cache Headers

Another is to use cache control headers to control how browsers cache CSS files. By setting the headers, you can specify the caching behavior for the CSS files.

protected void Page_Load(object sender, EventArgs e)
    Response.Cache.AppendCacheExtension("no-, must-revalidate");

In the above example, we are using the Response.Cache object to set cache control headers. By setting the cacheability to HttpCacheability.NoCache and appending the cache extension to “no-store, must-revalidate”, we are instructing the browser not to cache the CSS file.

Method 3: Modifying Web.config

You can also modify the web.config file to control the caching behavior of CSS files. By adding the following , you can set the cache control headers for CSS files.


In the above example, we are setting the cacheControlMode to “DisableCache” for static content, which includes CSS files. This will prevent the browser from caching the CSS files.


By using one or a combination of the above methods, you can force browsers to reload cached CSS files when using ASP.NET themes. Adding a version number to the CSS file, using cache control headers, or modifying the web.config file are effective ways to ensure that browsers fetch the CSS files from the server.

Rate this post

Leave a Reply

Your email address will not be published. Required fields are marked *

Table of Contents