I installed and enable cache and UI in modules. This made it active with no info so it messed up the site. It would be better if the install mode was disabled rather than enabled.

It looked through all the site and came up with a huge list of css and js files. Not all of which are used, for example book module is core but I don't use it. All of these are ticked by default. What I want it to do is to see what I am using and suggest those for a block.

What happens if the site needs a.css, b.css c.css but the bundle only includes a.css and b.css? Does c.css still get sent or does this cache replace all css files (i.e. does it only remove css files in the bundle)? Same question for js files of course.

Comments

malc_b’s picture

One more question, how does this work with different themes? I use one theme for admin (no cache need then as only me logging in) and one theme for the site (cache needed).

malc_b’s picture

Right so I looked throught the code and it seemed clever enough to work out if needed to include files so I'm trying it out. I added a bundle, had a look through the source of the site page, then added all those files to the new bundle. Same for js. Enabled the module and looking at the web page source it now has the bundle and the page is correct.

However, when I'm logged in as admin I use a different theme and I don't want my site bundle to load as it messes up the css. How do I define which bundle loads for which theme? As far as I can see there isn't a way to do that. Given that users changing theme can be an option then the bundles should be theme specific.

What I have done which seems to half work is to remove the main style sheet from my bundle. That removes most of the mess up of the admin theme but it's still not quite right. The site page now loads 2 css files, the bundle and the theme style sheet.

malc_b’s picture

I've played around a bit more. I now have 3 bundles for css, basic, admin, site. Basic contains the common css files, site the site specific ones, and admin the admin specific ones. The module is clever enough to include basic+site for site pages and basic+admin for the admin pages. I guess it looks at what the page needs and if a bundle has it adds that bundle, but only once.

I haven't tried putting the contents of basic into admin and site as I doubt it is clever enough to work out which bundle is the best match. It will add a bundle if not all the files are required, which was what was messing up my admin theme.

It seems to speed up the pages and the version number is useful to force browsers to reload css files when you make a change to the css.

kkaefer’s picture

I installed and enable cache and UI in modules. This made it active with no info so it messed up the site. It would be better if the install mode was disabled rather than enabled.

Thanks a lot for all those suggestions! I changed the default status of bundle replacements to disabled and added a message upon installation to inform the user that she has to enable it manually.

It looked through all the site and came up with a huge list of css and js files. Not all of which are used, for example book module is core but I don’t use it. All of these are ticked by default. What I want it to do is to see what I am using and suggest those for a block.

Yes, the module scans the entire Drupal sites for files. In an earlier unreleased development version, it only added files to the list which have at least been used once, but it was a hideous task to browse through the entire website to see if some obscure site uses yet another CSS file.

You can exclude files from showing up in the list on admin/build/sf_cache/config/excludes. The ticks only indicate that the file may potentially be added to a page. If you uncheck a file, it means that it will never be added to a page under any circumstances (if it’s not included in a bundle). The same applies to bundles.

What happens if the site needs a.css, b.css c.css but the bundle only includes a.css and b.css? Does c.css still get sent or does this cache replace all css files (i.e. does it only remove css files in the bundle)? Same question for js files of course.

In that case, the bundle and c.css will be added to the page. The workflow is as follows: It first looks for any files which are in a bundle, adds that bundle and removes all files from the list which are already in that bundle. Then it takes the rest of the files and replaces them with the processed standalone version of the file. That also applies to JavaScript files.

kkaefer’s picture

One more question, how does this work with different themes? I use one theme for admin (no cache need then as only me logging in) and one theme for the site (cache needed).

Thank you for this very good suggestion. I can reuse the code from block.module for enabling/disabling blocks based on certain conditions. It is definitely on my to-do list.

It is also interesting to see the “stream” of your thoughts. I will write some additional documentation based on your first steps. Since I know how the module works, it’s a bit difficult for me to see where problems occur for new users. Keep in mind, however, that this module is not for the end-user but more geared towards being installed on large sites. E.g. it runs on NowPublic.com.

malc_b’s picture

When you say:

You can exclude files from showing up in the list on admin/build/sf_cache/config/excludes. The ticks only indicate that the file may potentially be added to a page. If you uncheck a file, it means that it will never be added to a page under any circumstances (if it’s not included in a bundle). The same applies to bundles.

I'm not total clear what you mean. I assume the excludes list just means that the files are not list on sf_cache page and so not turned into sf_cache files, nor replaced. The "added" is confusing since the files are already added by the theme. SF_Cache is replacing. I should not say lose my theme style.css because I ticked exclude by mistake.

The excludes list would seem useful for reducing the amount of info presented but perhaps it would be better as an include or by default set to exclude all. I know on my site there are unused themes and unused modules (some core) so leaving them out would simplify SF_Cache display.

UPDATE:

I tried this. I added all my spare themes to the exclude list. Gave me a long list of files excluded but did not change the display of the css page. Still have all the css files in the css directory too so has saved any site MB. I'm not really sure what it is meant to do then. If it just excludes from a bundle then all I have to do is leave that file out of the bundle.

kkaefer’s picture

Weird, excluding files should remove them from the CSS/JS listing page. Is it possible to get access to your installation so that I can see what fails?

malc_b’s picture

Tricky, I'm naturally not keen to give out admin access.

I put "sites/all/themes/zen" (without "") in the exclude list. It made that into "sites/all/themes/zen/*.*" (without "") and gave me a long list of files that excluded. For example, sites/all/themes/zen/style.css and sites/all/themes/zen/theme-settings.js . If then I go back to the main list..... Hmm. They are now gone. Odd I'm sure i looked at them. Perhaps something need to update or refresh. I put in Zen twice and deleted the copy. Now the css files list is as expected. Odd, but is working now so nothing to sort out.

kkaefer’s picture

Awesome! (I didn't want to trick you in giving out admin access; I rather imagined an interactive session over IRC/IM in which I'd ask you to do certain things to find out what happened).

I opened a separate issue for the theme-specific enabling of sf_cache at http://drupal.org/node/238148.

As far as I read this issue, I don't see any further unanswered support questions, so I'm closing this issue now.

kkaefer’s picture

Status: Active » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.