Extension, Module

Archived
Forum
(read-only)

Mustash

ExpressionEngine 2, ExpressionEngine 3, ExpressionEngine 4, ExpressionEngine 5, ExpressionEngine 6

Back to this add-on's main page
View Other Add-ons From Mark Croxton

     

Hook for CP Menu Item

Feature Request

lsmith
lsmith

I would like to add a CP menu item for Mustash, specifically for the cache clearing page, but the “cp_custom_menu” hook is not set in Mustash, so it is not listed when I try to customize the CP menu items. That hook is used in EE v3.4+, and previous plugins for the purpose don’t work any more. 

In general, since you are the super-expert, I’m wondering if you have an opinion on the general problem:
* Using EE’s own template caching, sometimes.
* Using Stash to cache partials / page areas alongside dynamic content.
* Need to allow quick cache-clearing for admins, but with EE + Stash it is laborious.

Adding menu items for quick access will help. But I’m wondering what your preferred approach to partial caching is.

lsmith
# 1
lsmith

Well actually I realize now I can add menu items as links directly to the CP page I want, even if the add-on developer did not add that hook, so for that part I’m good. Thanks.

Mark Croxton
# 2
Developer
Mark Croxton

* Using EE’s own template caching, sometimes.

You can of course, but these are limited. For example, there is a limit to the number of template caches. Editing an entry will break the entire cache. File based caching still runs through PHP.

* Using Stash to cache partials / page areas alongside dynamic content.

Yes, you can use fragment caching for parts of your template that are ‘global’, such as navigation, even when you are using full-page caching as well. This is because it speeds up subsequent dynamic page loads before they are cached. On a busy site that is frequently edited that can make a huge difference as cache rebuilds are triggered. If your site is only moderately busy, then don’t bother - just use full-page caching.

The most important thing is to carefully plan your URLs when caching full pages:
https://github.com/croxton/Stash/wiki/Caching

I would advise you to use static caching wherever possible.

* Need to allow quick cache-clearing for admins, but with EE + Stash it is laborious.

Design your cache-breaking rules carefully so the editors don’t need to manually clear the cache.

lsmith
# 3
lsmith

I very much appreciate your reply! One big issue however: when I go to set cache breaking rules, there are no hooks listed in the dropdown. I’m on the latest EE 3.5, but it was also happening in EE 3.4.7. To get this far I upgraded laboriously from EE 2.4…

I found an old discussion you had with EE devs regarding hooks changing, but it seemed at the time (2015) that they intended to keep hooks. Have you heard of my issue before?

lsmith
# 4
lsmith

OK, sorry again. I figured out that in the other settings panel I have to first choose plugins before any hooks will show up in the cache clearing rules. But it doesn’t say that in the help text anywhere, does it? Unless I’m missing that, I suggest adding a note.

Also, is there a hook for when templates change somehow, and get refreshed in the DB? Is that covered by something else already?

Mark Croxton
# 5
Developer
Mark Croxton

I figured out that in the other settings panel I have to first choose plugins before any hooks will show up in the cache clearing rules. But it doesn’t say that in the help text anywhere, does it? Unless I’m missing that, I suggest adding a note.

It’s there in the installation notes, maybe you missed it:
https://github.com/croxton/Stash/wiki/Installing-Mustash#configure-settings

Also, is there a hook for when templates change somehow, and get refreshed in the DB? Is that covered by something else already?

There is no hook, but there are a number of ways to approach this. You could add logged_out_only=“yes” to the caching tag so that caching only occurs when logged out. Alternatively or additionally, you could add replace=“yes” to any stash embed or caching tag to force them to replace on each view (you could make this a global variable in your config to easily switch it in all templates). Finally you could set the config value ‘stash_file_sync’ to TRUE to sync templates in your local/development environment to force templates to sync when changes are made to them (this won’t clear caches though, it only applies to stash embed file changes). However you decide to do it, make sure you test with caching enabled and file sync off so you can be sure things work as expected.