bobray / cachemaster Goto Github PK
View Code? Open in Web Editor NEWClear cache for a single resource
Home Page: https://bobsguides.com/cachemaster-tutorial.html
Clear cache for a single resource
Home Page: https://bobsguides.com/cachemaster-tutorial.html
Hello,
Tried to implement the auto-unpublish with CacheMaster enabled, but unfortunately it does not work as expected :(
Here is my bug report and my local corrections.
Related commits for reference:
9c45274
0ea93d8
When $modx->cacheManager->refresh(...) is called on OnBeforeDocFormSave event, MODX takes the values of pub_date and unpub_date from the database, not from event's $resource object.
Since we are in OnBeforeDocFormSave handler, the new values (pub or unpub) are not yet saved to the database.
Therefore, $modx->cacheManager->refresh will update the auto_publish.cache.php not for current resource, but for other resources with non-zero pub_date and unpub_date values.
If the submitted (but not saved yet) resource is the only with the unpub_date, the auto_publish.cache.php will not be updated.
With the current approach, the auto_publish.cache.php not updating when the user unset either pub_date or unpub_date, which was previously set. Inside OnBeforeDocFormSave unset values are empty and the condition is not satisfied.
My solution:
/* Bail out if we're not doing this object */
switch($event) {
case 'OnDocFormSave':
if (!$doResources) {
return;
}
$ctx = $resource->get('context_key');
// If pub_date or unpub_date are set, update the auto_publish cache
// if ($resource->get('pub_date') || $resource->get('unpub_date')) {
$providers = array(
'auto_publish' => array('contexts' => $ctx),
);
$providers_result = array();
$modx->cacheManager->refresh($providers, $providers_result); // Cache refreshes from database
if ($doDebug) {
my_debug($providers_result);
}
//}
return;
break;
case 'OnDocFormPrerender':
case 'OnBeforeDocFormSave':
if (!$doResources) {
return;
}
break;
Hi BobRay,
1: I think it would be nice to have an option to clear the cache of all parents on saving a child document up to the highest parent under the root/context.
For example: When I change/add a child resource to an overview/catelog then I now also have to save the overview/catelog resource to clear it's cache so that the changes will be visible on the frontend.
2: And would be clearing only the cache of the current context also be a nice feature?
My previous forum topic http://forums.modx.com/thread/96097/empty-cache-per-context-on-resource-save?page=2#dis-post-529055 (sorry BobRay, I haven't had time to test your snippet).
Kind regards,
Marten
I'm trying to put cachemaster on a production server, and it won't 'install'. It downloads correctly, extracts correctly, I've confirmed and explicitly set modx-core/components/ to 777 just in case that matters, though it shouldn't.
When I click on on the 'install' nothing happens. I can view the 'about', check for updates, all that, but it simply won't install.
I successfully installed the plugin on my dev server, which tends to have looser permissions than the live server, so I suspect some directory has to have some permissions, but I can't find which it is. Obviously if a directly needs to be writeable for installation that should be checked by the thing being installed as a matter of course, so if that's the problem, this would be a bug issue, not just an install issue.
I've searched my local system for all files/directories with 'cachemaster' after the successful install, and can't find any more directories where permissions might be an issue.
I tried 'updating' another out of date plugin on the live server, and it updated fine, no issues.
It would be very nice if CachMaster had a property for specifying a context in which to disable the automatic cache clearing button. Probably should take a comma-delimited list, with βallβ being the default.
Hi BobRay,
Just reading this year old thread where CacheMaster couldn't untick the Cache checkbox as Articles at the time didn't have one: http://forums.modx.com/thread/?thread=82287
Now Articles does have one I don't suppose there's a way of updating CacheMaster to untick this as well? Client is unintentionally constantly clearing multiple sites cache each time they save or edit a blog post :(
Many thanks,
Shaun
I installed CacheMaster in develop version of MODX, namely from the Git develop branch (2.3.0-dev). I used both default and custom plugin settings (via property set). But it doesn't seem to work. My resources don't get refreshed even on changing the content
field.
The site is installed with a custom config key so the cache files sit in a subfolder of core/cache/
. The error log shows nothing. What's the problem?
Hi Bob,
New to cachemaster and it doesnt seem to be working.
I call my templates using the include snippet e.g.
1
[[include? &file=assets/templates/index.php
]]
Say I have 2 pages Home and About
Home - uncached it has 10 queries and cached it has 1 if
1
Lets say CacheMaster is installed and both Home and About are currently cached and use 1 query. If I update Home and navigate to About and View source it states I am making 12 queries again instead of 1 implying that the entire site cache has been cleared and not just that of the Home page. I use the default settings in Cache Master properties and the Empty Cache checkbox is checked by default on all my resources.
Am I missing something? I'm also hosted on modxcloud.com
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.