Drupal — disable CSS cache

18,583

Solution 1

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...

Solution 2

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

Solution 3

For Drupal 7 just add this to settings.php:

$conf['page_compression'] = 0;
$conf['preprocess_js'] = 0;
$conf['preprocess_css'] = 0;

It will override the current settings on "Performance" (admin/config/development/performance), and if you delete the above lines you will see the original configuration after clean cache.

Solution 4

Have a look at Disabling the Drupal cache. That should get you going in the right direction.

Share:
18,583
Charles Yeung
Author by

Charles Yeung

Updated on June 07, 2022

Comments

  • Charles Yeung
    Charles Yeung almost 2 years

    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?

  • David Eads
    David Eads over 13 years
    If you are actively developing, drupal.org/project/devel (Devel module) is your friend. You can also clear the cache from the command line with Drush (drupal.org/project/drush)
  • jhedstrom
    jhedstrom over 13 years
    On trick I typically use when working locally on a site that is already in production (eg, the CSS aggregation is set in the db), is to place this line in my local settings.php file: $conf['preprocess_css'] = $conf['preprocess_js'] = 0;
  • Stan
    Stan almost 10 years
    If you're using Drupal 7, the settings are under /admin/settings/performance and the field is called "Bandwidth Optimization". Uncheck the "Aggregate and compress CSS files" checkbox.