It seems the browser (or is it a visual studio?) Caches the stylesheet and therefore any changes I make for


I am using a stylesheet as part of the theme, and it seems that both IE and Firefox (or possibly the VS version) cache this stylesheet as any changes I make to the stylesheet (e.g. changing attribute values, etc.) etc.) arent reflected in the displayed page. Any idea how to prevent the browser or visual studio from caching this stylesheet?


BTW - only the stylesheet is cached, not the whole page

Also, when I noticed that any changes made to arres stylesheets reflected on the displayed page, Ive switched from firefox to IE. The first time the page was loaded in IE, the page displayed as it should (reflecting all the changes Ive made to the stylesheet), but then IE also started caching the stylesheet

thanks

+4
source share
8 answers

If you have Firefox with a web developer toolbar, you can easily disable caching. You can also use Ctrl + F5 to refresh the page. Holding Ctrl tells the browser to force a refresh that ignores the cache.

+5
source

One option is to link to the stylesheet so that the browser does not cache it. I find this to be the case when it comes to things like facebook apps, etc.

<link type="text/css" rel="stylesheet" href="/styles.css?v=<%= DateTime.Now %>" /> 
+4
source

You can try adding version numbers to your css href:

<link rel="stylesheet" type="text/css" href="path/to/stylsheet.css?v1.0.1" />

The query string (v1.0.1) does not affect css as such, but if the number increases, the browser reloads the stylesheet ( stylesheet.css ).

+3
source

Having a build version is also a good idea:

[NE]

 protected string GetAssemblyVersion() { // get the version object for this assembly Version v = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; // or do it in pieces return v.Major + "." + v.Minor + "." + v.Build +"." + v.Revision; } 

[MARKUP]

 <link href="/path/to/style.css?v=<%=GetAssemblyVersion() %>" type="text/css" rel="stylesheet" /> 
+2
source

This guy has a script that you can place on your asp, FWIW pages

+1
source

You can try to press the toggle button when you click the refresh button - this always worked for me.

+1
source

As everyone said, press Ctrl + F5 to refresh the page.

If this does not work, is this the page you created, or is it part of a project that is shared in a group? Perhaps someone who has ever encoded it can cache stylesheets or pages so often to reduce traffic.

+1
source

You can try using meta tags to indicate that the page has expired. For instance:

 <head id="Head1" runat="server"> <title></title> <meta http-equiv="CACHE-CONTROL" content="NO-CACHE, must-revalidate, max-age=0" /> <meta http-equiv="expires" content="0" /> <meta http-equiv="Pragma" content="no-cache" /> </head> 

I found that these meta tags are not always taken into account by browsers. It seems that IE best detects that the page should not be cached / content has expired.

Otherwise, refresh the page to reload the content as suggested.

-Frinny

0
source

All Articles