Drupal — disable CSS cache - 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?

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

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

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

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.

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.

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.
Step 2: In this file, do your local template preprocess stuff like:
Additionally, you can flush all your caches for DEV only.

Related

New to Drupal 7: Trying to figure out CSS

I inherited an already built Drupal 7 site. I have been able to figure out many things. But I am unclear on the CSS. A found a folder full of long-named CSS files but the code is all minified and hard to read. The previous developer had to be using some tools or services to alter and change the code in a more readable way. Does any know what the deal is ?
Also, I cant seem to find any way inside Drupal to enter CSS. I do not even see any classes or ID assigned to the blocks, views, nodes, or fields. So I have no clue how they were able to customize this site at all even though they obviously did. It uses Bootstrap 3 as a theme. Can anyone help explain how this works?
I will try to figure out the essence of the informations you given.
First: You have a Drupal 7 installation with compressed css files based on Bootstrap. That sounds the theme use less or sass precompiler for the theme css and you have the production (builded) instance of the project. Without the uncompressed less/sass/scss files it will be hard to edit the css. if you have no way to get the source files, the best way you can try is to add a extra css file and write you own css in it.
Second: Drupal strictly separates the code from the administration interface. Your PHP, HTML, CSS and other codes (except the WYSIWYG output) should not be entered via the administration interface. That's the best practice way. But anyway, there is a couple of modules that allows to write code inside the Drupal backend like this https://www.drupal.org/project/extra_css_js
Third: As information for you, Drupal 7s End of life is on November 28, 2022 so the best and recommanded way for you is: Freeze the Drupal 7s Instance as is (only Sercurity Updates and Hotfixes) and relaunch the Project with Drupal 9.
Drupal theme css files are mostly located in theme folder like "theme folder/css/style.css". As above mentioned, it might be used css minify tool or module for theme performance aspects. If it is created by drupal tools/module then once cache clear it will delete automatically and regenerate with new one with updated new css code on after page visit. You can also add custom css file by hook alter.

Afterlogic Webmail Lite custom theme / skin

I would like to make a custom dark theme for a web client.
I tried everything but no matter what I changed I cannot get any changes to take effect. I found out this page in the documentation but I cannot get it to work:
https://afterlogic.com/docs/webmail-lite-8/developers-guide/creating-new-skin
Does anyone have some experience with this webmail client?
The recommended option for creating a new skin is to clone and rename one of the existing skins, and upon making changes to it, run gulp styles --themes YOUR_THEME_NAME command. Once this operation is performed, check static/styles/themes/YOUR_THEME_NAME and see if you get your changes reflected there. If the changes are in place, then it's probably browser cache causing it, try clearing it and see if that helps.
In fact, it's not required to deal with .less files, you can simply create a copy of an existing theme under static/styles/themes directory - but in either case, you need to make sure the new theme is listed in ThemeList section of data/settings/modules/CoreWebclient.config.json configuration file.

Updated CSS not appearing in merged file

A skin.css file has been updated on a DotNetNuke website, but the updated change to the file has not yet come through on the main css file.
Tried clearing the cache within DNN and no luck...
I'm not overly familiar with DNN and how it works, but isn't it supposed to get merged into the rest of the CSS files with the DependencyHandler.axd. This does not seem to have happened.
Anyone any ideas?
When you say it isn't showing up in the Main.CSS file, I am going to assume you are using the CDF functionality in the platform. If so, you can go to the Host/Host Settings page, and look for the Client Dependency Framework portion of the settings.
In those settings you can "increase" the version number, which should cause the files to be regenerated, you can also turn off CDF to allow DNN to just load the CSS and JS files normally which generally makes debugging things a little bit easier.

I can't edit a drupal module, the css location is incredibly difficult to find

I need to edit a css file that manages the position of certain buttons for a block.
Using Google Chrome to inspect the element, Drupal only gives me this information about the css file name: DSFJHjdfkvwvSDFVSFbvnhsdjnvjsdnfjbvw.css
Wonderful... that doesn't exist. How am I suppose to pinpoint the exact location of a css file? I've torn apart the css files within the styles folder in themes.
So basically finding the source code for everything in drupal requires you to find the needle in the haystack. Is there a way to find exactly what css files my webpage is using by using the admin panel??
Drupal, for performance reasons , aggregates all CSS files into one generated file so only 1 request Is needed to load all necessary styles.
You can disable this (not recommended on a prd site) by going to the performance settings in drupal config and disabling js and CSS optimizations.
Clear the cache and now you will see the specific file the CSS rule lives in when inspecting in chrome tools.
As a side note, it is not recommended to edit anything in a contributed module unless you contribute it back. Otherwise, when you need to upgrade to the next version of the module, you will lose your previous changes. I would just apply CSS rules in your custom theme that override the modules CSS.
Sorry if there are typos. This was written on my phone and I will clean it up when I am at my desk.
I think in your drupal configuration you have enabled the "Aggregate and compress CSS files" settings. Try disabling it by going to Configuration > Development > Performance. It might solve you problem.
You can revert back the setting after you have made changes.
Turn of the caching and then clear the cache. You should then get the correct location of the CSS rules. Once you are done with this, enable caching again.

Drupal: Multiple Stylesheets

I'm currently creating a custom Drupal theme for my company and I'm having trouble getting multiple stylesheets to load.
I followed the instructions on this page by adding stylesheets to the .info file in the format:
stylesheets[all][] = style.css
stylesheets[all][] = name2.css
etc...
However, when I load the page nothing changes and when I view source, it consistently lists style.css but seems to ignore the others. Am I misunderstood in the process of adding additional stylesheets? What could I be doing incorrectly?
Thanks for any help!
Make sure the ‘Optimize CSS files’ and ‘Caching mode’ settings on /admin/settings/performance are disabled. Try clearing the Drupal cache by hitting the ‘Clear cached data’ button on the bottom of that page.
Apart from the mentioned cache clear, You might also need to visit the theme-selection page once:
admin/build/themes/select
This is to make sure the .info-file gets read again (it's not read on every pageview if Drupal already read it beforo you modified it).
If you see the .css file in the source as "style.css", the CSS optimization is 'off' (when it's on the files have been aggregated to one or several css file with hashed filenames like 'css_1d74ed895e4b5634b0aa1e99c1d0a174.css').
Also, you don't have to turn CSS-optimization off, clearing the cache rebuilts it. While you develop the css files all the time though, it's best to turn if off so you don't have to clear the cache all the time. Turn it on after you're done, it's a really significant page-load booster (in fact IE css loader can break if you dont use the optimizer and have too many css files).
Just to make sure, the css-files should be in the same folder as the .info file (and not for example the parent theme of a subtheme).
PS: clearing cache is fast and easy with the excellent admin_menu module
( http://drupal.org/project/admin_menu ).

Resources