Drupal — disable CSS cache
Asked Answered
D

6

6

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?

Desorb answered 14/12, 2010 at 6:27 Comment(0)
S
15

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

Singlefoot answered 14/12, 2010 at 11:54 Comment(3)
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)Cruet
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;Spotweld
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.Lungki
C
3

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

Caliche answered 14/12, 2010 at 18:59 Comment(0)
U
1

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

Upanddown answered 14/12, 2010 at 6:31 Comment(0)
M
1

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.

Membranophone answered 15/2, 2018 at 19:2 Comment(0)
S
0

It’s advisable to use CSS cache for Drupal optimization. To check your changes in CSS simply go to “admin/settings/performance” in Drupal 6 and "admin/config/development/performance" in Drupal 7 and disable “Optimize CSS files" in Drupal 6 and “Aggregate and compress CSS files" in Drupal 7 instead of turning off caching completely.

Smoothbore answered 8/11, 2013 at 9:33 Comment(0)
O
0

This approach is version agnostic. The code in this example is for Drupal 7.

Step 1: @include a template preprocess file at the beginning of your template file. (if present). This file is not added to the repository (ignored for version control (Git)), so it is not distributed across environments and each dev can have its own actions and settings in this file.

@including the local template file.

Step 2: In this file, do your local template preprocess stuff like:

Disabling CSS and JS compression for Local Development

Additionally, you can flush all your caches for DEV only.

Oralee answered 21/1, 2017 at 5:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.