General developer forum

Purge Cache takes Forever with Boost and Child themes

 
Picture of Chris Kenniburg
Purge Cache takes Forever with Boost and Child themes
Group Particularly helpful MoodlersGroup Plugin developers

In Moodle 3.3 we are getting issues with long times to refresh the page when clearing cache or saving admin settings.  It seems to affect all boos-based themes.  Specifically we are concerned with Fordson on Moodle 3.3 but we noticed quite a big difference in refresh times with Boost and several child themes as well.  

Commenting out the following lines seems to help dramatically but we loose the icons obviously.  

@import "../../boost/scss/fontawesome/moodle-path";
@import "../../boost/scss/fontawesome/font-awesome";

Is this just how things are going to be or are we doing something wrong with the themes?

 
Average of ratings: -
poseypic
Re: Purge Cache takes Forever with Boost and Child themes
Group Core developersGroup Testers

+1 with this. We are seeing the same issue since Moodle 3.2.

Any changes to Boost theme itself, or any child themes developed based off Boost, take a long time to just load the next page. And you can imagine how painful it is for a theme developer...

 
Average of ratings: -
Picture of Kevin Wiliarty
Re: Purge Cache takes Forever with Boost and Child themes
Group Core developersGroup Plugin developersGroup Testers

I assume that this is the price for not having to run grunt to process the sass files as you edit them. The sass files need to be compiled to regular CSS before the browser can use them. You can maintain the sass and css in parallel so that the css is represented in actual files and is always ready. It looks to me like Boost processes sass 'on the fly' and keeps it in the cache, which is fine ... except when you clear the cache. Note that there are no `.css` files in Boost.

 
Average of ratings: -
Picture of Chris Kenniburg
Re: Purge Cache takes Forever with Boost and Child themes
Group Particularly helpful MoodlersGroup Plugin developers

I am seeing up to 30 seconds to refresh the page on localhost and about that or a bit longer on production site.   I was worried I was doing something wrong with my theme but it happens on all the child themes to one extent or another.

I am guessing this is just the way it will have to be for now?

 
Average of ratings: -
Picture of Marina Glancy
Re: Purge Cache takes Forever with Boost and Child themes
Group Core developersGroup Moodle HQGroup Particularly helpful MoodlersGroup Plugin developersGroup Testers

FYI tracker issue for this problem is MDL-58646

 
Average of ratings: -
Picture of Urs Hunkler
Re: Purge Cache takes Forever with Boost and Child themes
Group Core developers

@Maina, how did you at Moodle HQ develop the boost theme when each cache clearing and theme rebuild takes a long time? Did you use workarounds or did you just sit and wait? Or may there be other options?

 
Average of ratings: -
Picture of Urs Hunkler
Re: Purge Cache takes Forever with Boost and Child themes
Group Core developers

After a lot of deep core code debugging I discovered that the treepostprocessor called in the function post_process($css) in outputlib.php is the reason for the extreamly slow CSS generation. When I disable the treepostprocessor in the theme config.php the CSS generation is fast again.

$THEME->csstreepostprocessor = null;

What does the treepostprocessor in Moodle do?

 
Average of ratings: Useful (2)
Picture of Richard Oelmann
Re: Purge Cache takes Forever with Boost and Child themes
Group Core developersGroup Particularly helpful MoodlersGroup Plugin developersGroup Testers

Is that the bit that got added to deal with auto-processing the vendor prefixes?

 
Average of ratings: -
Picture of Urs Hunkler
Re: Purge Cache takes Forever with Boost and Child themes
Group Core developers

Yep, Damyon wrote so in the tracker »Time to reset caches (compile Boost) recently became 3x slower« https://tracker.moodle.org/browse/MDL-58646.

 
Average of ratings: -
Picture of Urs Hunkler
Re: Purge Cache takes Forever with Boost and Child themes
Group Core developers

The convenient SCSS compilers are written in C/C++ because the task is demanding. So it's no wonder that a PHP implementation takes very long. I will see if I can develop a »hack« to use a fast SCSS process instead for the work on the design. Iterative work on the theme will not be possible with the Moodle PHP SCSS compiling because each iterative step would take minutes - and there are many steps in the process.

Has anybody developed a way to use SCSS that is compiled fast? My basic idea is to compile the SCSS externally and include the resulting CSS file in the theme.

 
Average of ratings: -
It's only an avatar...
Re: Purge Cache takes Forever with Boost and Child themes
Group Core developersGroup Documentation writersGroup Particularly helpful MoodlersGroup Plugin developersGroup Testers

Surely it would be simpler just to add the FontAwesome CSS file.

 

 
Average of ratings: -
Picture of Urs Hunkler
Re: Purge Cache takes Forever with Boost and Child themes
Group Core developers

@Mary It's not only about the FontAwesome CSS, a major issue is the treepostprocessor.

And when these two issues may be solved the SCSS rendering in PHP is still much slower than with for example libsass. To get a convenient workflow it should be possible to use the proven standard SCSS renderers instead of the Moodle PHP ones.

 
Average of ratings: -
Picture of Richard Oelmann
Re: Purge Cache takes Forever with Boost and Child themes
Group Core developersGroup Particularly helpful MoodlersGroup Plugin developersGroup Testers

The problem with compiling the scss externally is that it then prevents the use of the rawscss and variables as settings

 
Average of ratings: -
Picture of Urs Hunkler
Re: Purge Cache takes Forever with Boost and Child themes
Group Core developers

@Richard, I could imagine that Moodle writes the user added rawscss and variables form settings as a user preset SCSS file for example in moodledata. This file can be included into any external process for compiling.

Because of the speed advantage during theme development external SCSS processing would be a big win.

 
Average of ratings: -
It's only an avatar...
Re: Purge Cache takes Forever with Boost and Child themes
Group Core developersGroup Documentation writersGroup Particularly helpful MoodlersGroup Plugin developersGroup Testers

@Urs,

They say that PHP7 appears to make Boost theme a lot quicker, so I tested this out on my website last night when I upgraded from 3.2 to 3.3 and sure enough all worked well.

Mary

 

 
Average of ratings: -
Picture of Richard Oelmann
Re: Purge Cache takes Forever with Boost and Child themes
Group Core developersGroup Particularly helpful MoodlersGroup Plugin developersGroup Testers

@Mary, yes I'm using php7 and although there is a delay, I've never had the issues to the extent reported 

@Urs, I wasn't so much thinking of theme developers who may have the skills and the inclination to set up Grunt etc and process the scss externally. But it would need to work for 'ordinary' (if there is such a thing) site administrators,including the many who don't have server access.  After all, a theme developer isn't the primary target for theme settings. 

Could it work something along the lines of the php classes for Imagemagick? Relies on an external process, but controlled via the php, so still from within the main Web page code? (given that still requires additional php plugins installed, but we already have that with Moodle) 

R

 
Average of ratings: -
Picture of Chris Kenniburg
Re: Purge Cache takes Forever with Boost and Child themes
Group Particularly helpful MoodlersGroup Plugin developers

I am noticing about a 30 second to 45 second delay once you purge cache.  Never anything more than that.  So it is not unbearable but it does make testing a bit of a chore.  

 
Average of ratings: -
Picture of Urs Hunkler
Re: Purge Cache takes Forever with Boost and Child themes
Group Core developers

I am testing a »hacks« based workflow now with libsass in an external process and the compiling is done nearly instantaneous. With this workflow I can iterate. The »hacks« process seams to work, I don't know if Moodle will compile the same CSS when I remove the »hacks«. That I need to test.

Btw I work with the Mac program »CodeKit«, which is a web design build tool somehow similar to Grunt but with a GUI, which I prefer.

 
Average of ratings: -
Picture of Urs Hunkler
Re: Purge Cache takes Forever with Boost and Child themes
Group Core developers

Someone from Moodle HQ mentioned that the external process could be optional. Something like - if an external process exists use it else use PHP. That would be great.

 
Average of ratings: -
Picture of Andrey Mindubaev
Re: Purge Cache takes Forever with Boost and Child themes
 

Moodle could create all necessary files with rawscss and settings, @import all created files and sources files, and after that run external scss.

 
Average of ratings: -
Picture of David Penner
Re: Purge Cache takes Forever with Boost and Child themes
Group Core developers

Seeing the same. Glad to see I'm not the only one!

In my case, until I disabled xdebug, I was having to wait upwards of 2 minutes (this is on a quad core virtual server with plenty of RAM sitting in my institution's data center) when purging caches or while using theme designer mode. Disabling xdebug brought it down to the 30 seconds others mention here. Which is still far too long for effective iterative work while theming.

 
Average of ratings: -