Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drupal — disable CSS cache

Tags:

drupal

I am using Drupal 6. Every time I modify the CSS files, I need to clear the cache to see the updated result, which is a waste of my time. Is there any way to disable the cache system?

like image 447
Charles Yeung Avatar asked Dec 14 '10 06:12

Charles Yeung


People also ask

How do I disable caching in Drupal?

Navigate to admin/structure/views/settings/advancedCheck the Disable Views Data Caching option.

How do I disable cache in Drupal 7?

And/or install Admin Menu and hover over the Drupal icon in the top left corner, then on "Flush all caches".


2 Answers

The reason the CSS cache needs refreshing is because Drupal optimizes all individual CSS files from various modules and themes into one CSS file which is optimized into a single file.

So that this file is not recompiled every page load, which would loose the benefit of optimization, Drupal needs to know when the CSS file has changed in order to recompile this. At which cache refresh seems like the ideal time. To turn this off - rather than turn off caching completely you can simply:

Go to /admin/settings/performance where there is a field labeled "Optimize CSS files":

Disable this whilst you are doing your development and making changes to your CSS file. Then when in production and most of your CSS is set then you can enable it. I highly recommend the performance gains this brings in the loading of your pages.

I have the administration menu module installed, and it is very easy to empty the cache from here in a single click - have a try...

like image 160
Richard Avatar answered Oct 21 '22 15:10

Richard


Also, for the purpose of development you could place the following in your template.php (assuming you're working on a theme).

drupal_flush_all_caches();

See http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_flush_all_caches/6

like image 39
Michael Hellein Avatar answered Oct 21 '22 16:10

Michael Hellein