External CSS and Cache (Full Version)

All Forums >> [Web Development] >> Cascading Style Sheets



Message


John Morch -> External CSS and Cache (7/24/2005 21:07:35)

Maybe a dumb question but here goes.

When developing you need to correct external CSS files a few times.
The old ones get stuck in the cache (in my case a ISA 2004 one on our broadband connection)

How to you force the external style sheet to be refreshed?

John




womble -> RE: External CSS and Cache (7/25/2005 3:48:10)

Either empty the cache in your browser. In IE it's tools>Internet options>temporary internet files>delete files>delete all offline content>OK. In FF it's Miscellaneous>Clear cache (on the developer toolbar) - there's probably a way to do it not using the developer toolbar, but that's the quickest.

Or you may be able to get away with just refreshing your page - Ctrl F5 in IE and Ctrl R in FF (I can't remember what it is in the others off-hand).




John Morch -> RE: External CSS and Cache (7/25/2005 4:05:29)

Let me re-phrase the question

In an html page you can set cache control, timeouts etc.
How can you do the same in the css file that is also stored in the caches (especially the one in a ISA 2004 server that many large companies use to minimise bandwidth).

John




jaybee -> RE: External CSS and Cache (7/25/2005 4:34:13)

Good question John and I have no idea. It's something that drives me nuts as well and not just with css, any includes. If I come across anything I'll let you know.




jaybee -> RE: External CSS and Cache (7/25/2005 4:52:05)

OK, found the following and it's pretty much what I end up doing. I don't think there's any other way.

quote:

Browser caching

Sometimes a browser will cache your Thoth documents. Refreshing a page does not refresh any cached pages. Often, XML documents or CSS documents are cached to make sites run faster. Unfortunately, if you change a Thoth document or a stylesheet, then the changes will not show up since the browser doesn't refresh such cached pages. I have often found myself making changes to my Thoth code or my stylesheets, then I test the application in Safari, and it doesn't seem to be changing at all. Naturally I assume my code is wrong so I spend unnecessary time trying to figure out what is wrong. In the end I realize it's just that the page has been cached by the browser.

Holding down Shift and clicking the refresh button sometimes refreshes all cached pages in most browsers, but sometimes it doesn't refresh XML and CSS documents. To refresh these pages, you need to open those pages in your browser and only then hold down Shift and click the refresh button. For example, if absconditus.com/index.html uses a Thoth document named main.xml, and I need to refresh main.xml, I need to open absconditus.com/main.xml in the browser, refresh it, and then open index.html again. That usually does the trick. Sometimes you can also set the browser's Preferences to refresh all pages every time you visit a page, and this usually takes care of the problem. If you have control over your META tags, you can use them to refresh the page each time a user visits.

In any case, refreshing these pages is becoming a standard part of my debugging/development process when things aren't working right, and caching is often the culprit. If you're working with XML and/or CSS, always check for caching problems, even if you're not working with Thoth.




John Morch -> RE: External CSS and Cache (7/25/2005 4:58:11)

Thats what I always do as well. I was just hoping that there was a way force CSS and includes some way.
Often you are talking to a client on the phone and updating the site at the same time. When the cacheing upstream gets in the way the ctrl refresh does not work on those files.
With using frontpage I often will rename the css file and of course republish the whole site. OK for new sites under development but not live ones!!!

Maybe someone will let us know a way to force refresh these file types as they are becoming more used!!




jaybee -> RE: External CSS and Cache (7/25/2005 5:20:16)

Well I've been searching for a way for over a year now and had no luck. I'll see if I can talk to a server expert.




dpf -> RE: External CSS and Cache (7/25/2005 10:06:10)

that technique allows the developer to refresh but how do you teach it to every visitor? i get that a lot where user/clients cant see my changes




thig95 -> RE: External CSS and Cache (8/9/2005 11:03:21)

Hey, so i just came across this forum and i'm having a similar problem. I'm currently developing a web application which is written primarily in PHP and also uses CSS files. I'll be making my changes to the main .css file and the index.php file without problems and then all of a sudden my browser will just stop refreshing the new changes.

What is interesting to me is that it is not a problem specifically with my browser, as I tried to load the page on a laptop which hasn't viewed the page for days and what loads is what i'm seeing on my dev computer. So i'm guessing issues like this must be server related, but i'm just an admin and def no expert. Maybe we can try and find out if Windows 2003 server has some mechanism that is preventing the changes to be applied right away if a file has been altered more then a set number in a given time period. That would make sense to me because i usually run into this problem an hour or so into development.

Any thoughts??

~Brian Polk
Senior Technical Support
Delta Financial Associates
brianpolk@deltafin.com




danrendrag -> RE: External CSS and Cache (10/25/2005 23:43:09)

I too have had the same issue many times - drove me nuts!

Here's my solution:
To get around the problem of caching the css file while developing, I copy the existing css to a new file (ex: dev-css.htm), add opening & closing style tags and then call the file with an include in the document head. (also disable the external style sheet reference)
The end result being embeded styles - If the page refreshes, so does all the underlying markup.

When finished, I merge the changes back into the original css file and reconfig the page(s) to use <link rel...

Actually, you could simply use this technique instead of <link rel... and never look back - haven't done that myself though.

Dan Gardner





Tailslide -> RE: External CSS and Cache (10/26/2005 2:58:13)

My solution was similar to your Dan - I have a normal link to a stylesheet called whatever.css (the normal link deals with fouc problems) and in whatever.css I have nothing but a @ link or links to the actual stylesheets (thus filtering out all the ancient browsers that don't like CSS much).

When I do major changes in the CSS I just change the name of the CSS file linked by the @ in whatever.css. When a new name is used for the CSS file the browser will always go look for it. In a way it's sort of like using includes - just have to change the stylesheet name and the name in whatever.css.




jaybee -> RE: External CSS and Cache (10/26/2005 5:12:40)

Hmmmm thanks for that guys, I'll give it a go. I'll have to see if something along those lines will work for other included stuff as well.




Phil Bathe -> RE: External CSS and Cache (5/9/2006 12:54:48)

Try adding a ? to the end of the link ie: "includes/style.css?"

- it is probably very wrong and upsets the purists but it seems to work on FF and IE - I'm guessing because it has to parse the querystring (even tho its empty) or some such type of technowotsit




rdouglass -> RE: External CSS and Cache (5/9/2006 13:16:06)

Personally I usually put all my CSS in a style.asp file as an include while I'm developing. Cures most all caching issues.

I can do final tests by changing only 2 lines and renaming the file to style.css.




feebool -> RE: External CSS and Cache (1/24/2008 5:07:08)

http://www.sharepoint-tips.com/2007/11/avoiding-css-caching-issues.html
I haven't tried it yet (doing the rename thing), but I will for next time.
Annoyingly even if I get the stylesheet to load it is now caching the imagefiles that are used as background: url ## IN the css files, so I have to change those by hand too.

Perhaps I could make a development user that does not have caching enabled on the server.




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.078125