Reputation: 1153
I’m using a stylesheet as part of a theme and it seems that both IE and Firefox ( or perhaps VS express edition) are caching this stylesheet, since any changes I make to a stylesheet ( such as changing attribute values etc ) aren’t reflected on the displayed page. Any idea how to prevent browser or visual studio from caching this stylesheet?
BTW – only stylesheet is cached, not the entire page
Also, when I've noticed that any changes made to a stylesheet aren’t reflected on a displayed page, I’ve switched from firefox to IE. The first time the page was loaded in IE, page was displayed as it should (reflecting all the changes I’ve made to the stylesheet), but then IE also started caching the stylesheet
thanx
Upvotes: 4
Views: 3680
Reputation: 1378
Having the assembly version is also a good idea:
[CB]
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" />
Upvotes: 2
Reputation: 3938
You could try using meta tags to indicate that the page is appears to be expired. For example:
<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 have found that these meta tags aren't always taken into consideration by browsers. IE seems to be the best at detecting that the page shouldn't be cached/the content is expired.
Otherwise, refresh the page to reload the content as has already been suggested.
-Frinny
Upvotes: 0
Reputation: 75
As everyone said, press Ctrl+F5 to refresh the page.
If that isn't working then, is this a page you designed or is it part of a project that is shared in the group? It's possible that who ever coded it might be caching the style sheets or page every so often to reduce bandwidth spent.
Upvotes: 1
Reputation: 10865
One option is to link to the stylesheet in a manner that doesn't allow the browser to cache it. I find this is th case when dealing with things like facebook apps and such.
<link type="text/css" rel="stylesheet" href="/styles.css?v=<%= DateTime.Now %>" />
Upvotes: 4
Reputation: 253318
You could 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) doesn't affect the css as such, but if the number increments the browser reloads the stylesheet (stylesheet.css
).
Upvotes: 3
Reputation: 5022
If you have Firefox with the Web Developer toolbar, you can easily disable caching. You can also use Ctrl+F5 to refresh the page. Holding Ctrl tells the browser to perform a forced refresh that ignores the cache.
Upvotes: 5
Reputation: 70523
You can try hitting the shift button when you click the refresh button -- this always worked for me.
Upvotes: 1