Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Force Reload of CSS Style Sheet

Status
Not open for further replies.

jbenson001

Programmer
Jan 7, 2004
8,172
US
Hi all,

Not sure if this is the right forum, so let me know..

To force the reload of images I know you can append a querystring to the end of path of the file. Can the same thing be done to force the reload of a CSS syle sheet?

Thanks,

Jim
 
Doesn't that defeat their objective a bit? You may as well use <style> tags in the page if you don't want the styles to be cached.


____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244 on how to get better results.
 
It's only good being cached until it the CSS changes. We just ran into a problem where we rolled out code with some new CSS and the page wasn't displaying correctly on some machines because the CSS was cached. Some people may know how to fix the problem by refreshing, but this is a public website so I doubt most people know what the problem is or how to fix it. So we thought of the forced refresh because having it cached really isn't going to save any bandwidth or time downloading the page, and will only irritae users if a navigation bar, etc. doesn't work correctly.
 
Personally, I think appending a random value for a CSS file is a very bad idea as you will be going against the whole idea of caching files. Using a CSS file normally will save time and bandwidth as the file doesn't have to be requested again and can just be displayed from the user's cache so I'm not sure what you mean by saying it won't save either of those. Also, most browsers have their default option set to check for a new version of a file automatically anyway so once it clears it's cache up, it will request the new file.

If you really are worried about user's browsers using a cached version of your CSS file, and want to eliminate this altogether, why not just change the name when you roll the application out? This way a refresh will happen when you've made a change but otherwise your users can still benefit from using the cached file and therefore the page load time will be quicker.



____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244 on how to get better results.
 
I understand that CSS files are meant to be cached. However in this instance, since there were significant changes to it, having a cached version is causing problems. This is a rare case where it would be nice to not have it cached. Also, most of our users are using IE and the default is NOT to check each time a page is requested(it is defaulted to Automatic).
Changing the name did come up, but the lead on the project decided against it, although that seems to be the best way.




 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top