In an effort to minimize the amount of site cache clearing that goes on in a large site I've been working on, I've found out a lot about what triggers a complete site cache clear, and I have to say I'm not happy about it! I use CacheMaster to prevent clearing the cache every time an edit is made to a page, and that works great for the most part, but it has no control over several ways the cache gets cleared.
1. Installing a new plugin clears the cache. Why??? I haven't even used the plugin yet, and maybe it's just to add some scripting ability that I haven't even put in a page yet, and even so I would just need to save that page and clear the cache just for that page.
2. Creating a new page automatically checks off the "clear cache" checkbox, even if I haven't set that page to be published yet. Once again, what's the point until it's published? I'd like to see an option in CacheMaster to disable this on new documents.
3. The Publish and Unpublish buttons in the list views of plugins like Articles and Collections clear the cache.
4. Right-clicking on a resource in the tree and selecting Publish or Unpublish or Delete, and also using the Quick Edit option here, clear the cache.
I'm sure there are other times the cache gets cleared automatically. It drives me nuts.
1. I'd love to see a system setting that makes it an option to NEVER clear the site cache no matter what happens, so that the cache only gets cleared by selecting Clear Cache in the MODX menus.
2. I'd love to see an option to designate a certain area of the site as an "archive", so that the site cache for these files never gets cleared, even when selecting Clear Cache from the MODX menus. Maybe selecting that would bring up an option to include or exclude pages in the archive. I have one site that's fairly small except for one section that has tons of old articles available, and after a site clearing, whenever a search engine hits this site for reindexing, all those thousands of articles have to be needlessly reacreated all over again.
I know there are other cache-related plugins available, but I don't think they address these problems.
Good points, especially #1 and #2.
Keep in mind, though, that many MODX users don't really understand the cache system and how MODX objects depend on one another. The problem is that when you make a change, there's no practical way for MODX to know what upstream objects are making use of the the object you're changing.
When you unpublish a resource, for example, if you don't clear the cache it will continue to appear in Wayfinder and getResources output even though it shouldn't. The opposite happens when you publish it. It *won't* show up in the Wayfinder and getResources output even though it should. On certain sites, this could be disastrous -- imagine unpublishing a resource that contains libelous or illegal content and having it continue to show up, or publishing an important security warning but having it fail to appear in the front end.
In addition to the legal and moral implications, there's the issue that MODX will seem like an unreliable platform to many new users when changes they make have no effect in the front end of the site.
Your idea of having configuration settings to control what's cleared and when is excellent, imo, though I'm not sure how difficult it would be to implement.
In theory, you can create your own cache handler class that extends the MODX xPDOFileCache class, put it in the xpdo root directory, and tell MODX to use it by changing the cache_handler System Setting. Your class could override the parent's methods and evaluate conditions before calling the parent's method, but I've never done it and I'm not sure to what extent the information you need would be available at that point.
I educate all my clients thoroughly about the MODX caching system, and about how and why to clear the cache, so there is little chance your first three paragraphs will apply to them.
Your idea about the cache handler sounds interesting, but is way beyond me at this point! If only I had lots of time on my hands . . .
That seems to only control what happens when you save resources. It DOES turn clear cache off when you create a new resources, which is nice. But it doesn't prevent the cache getting cleared when you delete one, or when you publish/unpublish by control-clicking, install plugins, etc.
[ed. note: rainbowtiger last edited this post 6 years ago.]
<sigh> Now I have to clone my fork of Revo again, sync everything, fix the delete and publish/unpublish processors, then push and make a pull request. Well, at least I'm starting to get the hang of how to do git and github.
Elements I haven't looked into at all.
Heh. It clears on undelete, too.
Ok, patched delete/undelete and made a pull request. Will do publish/unpublish later. I suppose it will get easier with more practice.
Delete button needs to be converted to an undelete button, but that's Ext stuff and I don't even want to go there. As if I could.