Reputation: 51
Is there a possibilty of caching when a css file is added like this:-
<link rel='stylesheet' type='text/css' href='rstyle_sheet.css'>
as changes done in that file are not getting reflected immediately.
If Yes, Any way to counter that..?
Upvotes: 0
Views: 764
Reputation: 346260
CSS stylesheets referred to that way are cached like every other resource, be it HTML pages, Javascript files or images.
And like every other resource, you can influence the caching behaviour via the HTTP headers Expires: and Cache-Control:. That means you either have to change the webserver configuration, or have the CSS files served by a PHP script rather than as plain text.
Upvotes: 0
Reputation: 9377
If you are developing and don't want the cached version turn off caching in your browser.
I use the following combination of tools: Firefox + Web Developer Toolbar and then Disable > Disable Cache
Upvotes: 0
Reputation: 4691
Yes, add a timestamp after the css file name, like this:
<link rel='stylesheet' type='text/css' href='rstyle_sheet.css?1312843018'>
And update the timestamp each time you change the file. Lots of frameworks like ruby on rails etc do this for you
Upvotes: 0
Reputation: 1487
Most browsers cache CSS
You could add a version number to prevent it:
<link rel='stylesheet' type='text/css' href='rstyle_sheet.css?v=2'>
Upvotes: 1