2

I'm responsible for my company's webpage, and I'm having caching issues when updating it with the new CSS files. The CSS files are collected and minified as they should be, but when I update them, they should be cleared, so the page looks like it should.

How do I clear the cached CSS files in Drupal 7?

3
  • If the css are collected and minified properly (and I assum stored in the right dir with the same name as the previous version of the file) the problems seems to be on the client side, files being cached in the browser. If you hit ctrl+f5 does the page render properly?
    – Geeo
    Commented Feb 5, 2013 at 16:02
  • The page rendered properly for me, however some co-workers experienced that they got the old faulty CSS cached from their browser. When they cleared the cache they got the correct CSS. This isn't a problem at the office of course, but if they get old CSS so will some customers I presume?
    – Johan Dahl
    Commented Feb 5, 2013 at 16:16
  • Yeah, this is exactly what I'm talking about. It's not a matter of telling drupal to clear the cache but the customers have to clean their client-side chache. There is no general way to force them to clean the cache. Here stackoverflow.com/questions/2185872/… you can find a discussion about it (not drupal oriented)
    – Geeo
    Commented Feb 5, 2013 at 16:26

3 Answers 3

3

Navigate to http://mysite.com/admin/config/development/performance and click the "Clear all caches" button :)

enter image description here

Or if it's an option, install drush on your server and use drush cc css-js, it will only clear CSS/JS cache so won't slow the site down while all the caches are rebuilt.

4
  • For some reason, that button doesn't seem to do anything for me. I don't know why, but I had to clear my cached pages by removing the generated html-pages in the cache folder. That doesn't clear the CSS/JS though. But I guess I could remove them from wherever they are stored aswell, and new ones would be generated?
    – Johan Dahl
    Commented Feb 5, 2013 at 15:48
  • Is it possible the web server can't write to the sites/default/files folder? That would stop it being able to clear the cache files. Checking the watchdog for evidence of that would be a good idea
    – Clive
    Commented Feb 5, 2013 at 15:53
  • Yes I'm having some permission issue (with Boost I think). I have to clear my cache through FTP and even then I have to do some sudo command to get permission first, every time :( What is Watchdog?
    – Johan Dahl
    Commented Feb 5, 2013 at 15:59
  • 1
    If you have the DB log module enabled you can find recent PHP messages at /admin/reports/dblog...it might help to work out what's going wrong
    – Clive
    Commented Feb 5, 2013 at 16:00
1

If you use drush then you can use the command drush cc css-js

2
  • I don't use drush. Heard about it and it seems nice, will check it out.
    – Johan Dahl
    Commented Feb 5, 2013 at 15:48
  • 1
    It's well worth the setup effort, saves loads of time in the long run :) Commented Feb 5, 2013 at 15:53
1

You are confusing "client-side cache" with "server-side cache". Your problem is generated by clients caching the css of your site. How does it work? When the browser requests the css file and it finds out it already has one with the same name in the cache associated with your domain, it doesn't download it again but keeps using the one it has for improved performance. So, even if you modify your css but you give it the same name, the client browser won't know the difference and it keeps using the old one [unless the clients hits F5 or Ctrl+F5 in most browsers, effectively ignoring the cache]. It's not a matter of flushing Drupal (server-side) cache. They are totally unrelated.

You may want to check this module: http://drupal.org/project/advagg

3
  • @Downvoters: care to comment?
    – Geeo
    Commented Feb 6, 2013 at 11:12
  • Thanks. Yes I was not clear of what the problem was. It's client side yes. But I thought that since the js and css are compressed and get's new filenames, the browser would pick that up and realise that it's not the same files. Will check out that module.
    – Johan Dahl
    Commented Feb 13, 2013 at 16:29
  • Glad it helped. I have never used that module myself but the solution is creating css/js with different names on every deploy and it seems that module covers this aspect.
    – Geeo
    Commented Feb 18, 2013 at 10:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.