Drupal — disable CSS cache

2019-02-17 04:59发布

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?

标签: drupal
6条回答
劫难
2楼-- · 2019-02-17 05:14

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.

查看更多
劳资没心,怎么记你
3楼-- · 2019-02-17 05:18

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

查看更多
贼婆χ
4楼-- · 2019-02-17 05:28

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

查看更多
等我变得足够好
5楼-- · 2019-02-17 05:29

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.

查看更多
迷人小祖宗
6楼-- · 2019-02-17 05:31

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

查看更多
▲ chillily
7楼-- · 2019-02-17 05:31

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.

查看更多
登录 后发表回答