Clear cache of a specific theme

Clear cache of a specific theme

by João Vitor Ferraz -
Number of replies: 15

Hi, i would like to know if is possible to clear the cache of only a specific theme or page? because purging all the cache or activating designer mode makes refreshing too slow...

Moodle Version: 3.2.1

Average of ratings: -
In reply to João Vitor Ferraz

Re: Clear cache of a specific theme

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

In top of Theme selector page 

In reply to Mary Evans

Re: Clear cache of a specific theme

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

I've been thinking about this and even though there is a 'Reset theme cache' button, this would be for everything as when TDM is off the 'all' and 'all-rtl' files get created containing all of the CSS.  Which presumably is other themes if course / category themes are enabled.  Therefore I don't think its possible because the CSS already is just the selected theme (or more given settings stated) combined with the other plugin CSS too.  But if only one theme then you won't see any performance increase by trying to work out a theme specific means of clearing the cache as everything is lumped in together anyway.

Average of ratings: Useful (1)
In reply to Gareth J Barnard

Re: Clear cache of a specific theme

by João Vitor Ferraz -

So there is no way to make refreshing faster? There is a way to tell moodle to not save the css in cache at all?

In reply to João Vitor Ferraz

Re: Clear cache of a specific theme

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers

The way to not save the css in cache at all - turn theme developer mode on

But what is the issue that is making your theme so slow to refresh when making the changes?

Standard css does slow it down, but that is the difference between designing and using in production and it is a trade off.

Some of the bootstrapbase themes that compile LESS on the fly are very slow to do that when rebuilding the cache, partly because of the number of settings that hit that process - e.g. More does it and isn't too bad, Flexibase does it and is terrible for speed when theme designer mode is enabled because it regenerates the LESS on the fly every page load and there are lots of settings that hit that process - As a result I got into the habit of leaving TDM disabled and just hitting Purge All Caches when I need to. Yes that slows it down when you do it, but you only do it when you know you've made changes that need the cache refreshed.

The other way might be to have your moodledata folder from your server open, you could then have the [moodledata]/localcache/theme folder open and find your particular theme cache in the subfolders there and manually clear that specific cache folder (or as Gareth points out - caches for multiple themes if you have more than one theme active in courses and categories). I'm not convinced this will improve any speed issues when rebuilding the cache over the clear themes cache button suggested by Mary or the TDM, but you could try it and see.


Richard

In reply to João Vitor Ferraz

Re: Clear cache of a specific theme

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Two possible ways:

  • Perform a performance profile of the page load when clearing the cache and identify any bottlenecks in the code, work out solutions, raise tracker issue(s) as enhancements, wait, wait a bit more, finally get into the next version of Moodle (currently 3.4 as 3.3 is now frozen) as enhancements.
  • Perform a performance profile of the page load when clearing the cache and identify the slowest element of hardware, go out and get a faster version of slowest hardware.

And ditto to what Richard says.

In reply to Gareth J Barnard

Ang: Re: Clear cache of a specific theme

by Ole Frank Jensen -

I also have massive performance problems when "Designer Mode" is ON. 

I have no custom code. I just completed the tutorial on creating a new theme from Boost.

I'm on a brand new Mac I7 16GB ram. Running MAMP


When changing 1 property (h2 color) the page reload ~25 secs. Is this normal in moodle land? Any tips?

In reply to Ole Frank Jensen

Re: Ang: Re: Clear cache of a specific theme

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers

What moodle version are you using?

If you are testing on 3.3dev, then apparently the fontawesome scss has recently been added and caused an even bigger performance issue around caching - actually the performance isnt sprcifically around the caching its around the pre-processing of the scss.

Personally, Ive taken to not using the theme designer mode, just having the purge all caches link handy when I need it, so that styles and scss are not processed every page load.

In reply to Richard Oelmann

Ang: Re: Ang: Re: Clear cache of a specific theme

by Ole Frank Jensen -

@Richard Oelmann:

I'm on 3.2.2 (latest stable).

When styling a theme I need to continuously process the scss in order to see the progress of my work.

Where do I find the "Purge all caches" link?

And: do you know if it's possible to process the scss my self? Maybe it's possible to process it with gulp (should be much quicker than moodles built-in proc) and maybe using a proxy tool like Charles to inject the css during development...

In reply to Ole Frank Jensen

Re: Ang: Re: Ang: Re: Clear cache of a specific theme

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers

Purge All Caches is at Site Administration > Development > Purge All caches, or I just leave a tab open with that page in my browser so I can click it as needed.

'Need to continually process the scss' - Understand that, but theme designer mode forces that on every single page load, not on every single change you make. Sometimes you need to be able to navigate around and see the effect of a single change on multiple pages. Purging the caches once then navigating is a lot quicker than theme designer mode forcing the re-processing of everything every page load.

Im sure you can process the scss yourself externally, but I'm not sure its that beneficial, but if it will help your workflow, then thats upto you. Personally, I dont think it would help mine (but emphasis on the 'personally') smile You'd probably have to make sure all of the Boost settings and processing were disabled somehow or run it as a complete clone of boost with all of that extracted (Please see other threads about the significant disadvantages of running a clone of boost rather than a child).

Have to say that having built 3 themes on Boost now (one on the plugins database and 2 still in progress as my own learning and development), I'd prefer to simply use the Purge All Caches tool than theme designer mode or external processing. But again, would comment that is a personal choice and what I find works for me. I'm not saying it is the correct/best/only way to work!


Hope that helps

Richard


In reply to Richard Oelmann

Ang: Re: Ang: Re: Ang: Re: Clear cache of a specific theme

by Ole Frank Jensen -

Thank you very much for your helping comment. Im sticking to the Purge All Cache option for now.

In reply to Ole Frank Jensen

Re: Ang: Re: Clear cache of a specific theme

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Yes...in some cases I have had it take longer with Theme Designer Mode turned off, but then I am using Moodle 3.3 dev which has issues.

My advice to you is turn TDM off and make your changes in the Raw SCSS in the Advanced setting of your new theme, assuming of course your theme has such a setting?

After saving your settings it should take only a few seconds to display the page with your changes.

Hope this helps?

Mary

In reply to Mary Evans

Ang: Re: Ang: Re: Clear cache of a specific theme

by Ole Frank Jensen -

@Mary Evans:

Thanks for the help but I'm not sure what you mean?

I'm using a Moodle Package for Mac, 3.2.2 ("latest stable").

What do you mean by "changes in the raw SCSS"? I'm changing directly the .scss file already. And what is "Advanced setting of my theme"? 

I'm a experienced frontend dev used to writing scss and javascript for years. But I'm new to moodle...

In reply to Ole Frank Jensen

Re: Ang: Re: Ang: Re: Clear cache of a specific theme

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers

'Raw SCSS' is one of the settings on the Advanced Settings tab within the Boost theme settings itself.

Its often handy to be able to test scss changes there and then transfer them to a preset when you know you have what you want (or leave them there if they are site specific rather than changes to a theme under development).

In reply to Richard Oelmann

Ang: Re: Ang: Re: Ang: Re: Clear cache of a specific theme

by Ole Frank Jensen -

Ok thanks found it. It seems a very temporary option. Would much prefer to keep styling together in separate files smile

In reply to Ole Frank Jensen

Re: Ang: Re: Ang: Re: Clear cache of a specific theme

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

@Ole Frank

Sorry I had assumed that you have a settings .php file in your theme that contains a section that allows you to add SCSS, just like the Boost theme has which is found by navigating to...

Site Administration > Appearance > Themes > Boost

Then choose the seconed settings tab called  "Advanced settings"

Cheers

Mary