-
- 38 Posts
Hi all,
is it possible to set Modx so that cache is emptied only for the context the saved resource belongs to?
Regards,
alessandro
-
- 24,544 Posts
The CacheMaster extra will refresh the cache for just the resource itself, but I don't know of an extra that will refresh just that resource's context. Given the way the MODX cache works, I'm not sure it's possible.
-
- 38 Posts
Thanks.
Do you think a custom provider which writes the cache in a different folder could be a viable solution?
-
- 24,544 Posts
Yes, I think that would let you write a plugin attached to OnDocFormSave that would do it, although I think the default behavior is for MODX to clear the entire resource cache, so your code would be superfluous unless you turn that off (say with CacheMaster).
If you can figure out how the resource cache is organized (not all that complicated), it might be easier just to use CacheMaster, plus a plugin with code that just uses unlink() to delete the resource cache files in a given Context by id (easy to get with a fairly simple query).
Before you go to a lot of trouble, though, see what kind of performance you get from CacheMaster. It's usually unnecessary to clear the cache for all resources in a context just because you updated one.
Doesn't it do that by itself already?
-
- 24,544 Posts
Sorry, not sure what you mean by "it". MODX clears the whole cache, CacheMaster clears the cache for the newly saved resource. The OP wants to clear the cache just for all resources in the same context as the newly saved resource.
-
- 38 Posts
I was thinking of something different, a custom provider (that writes cache files to a different location, say core/custom_cache/ instead of core/cache/) specified as cache handler in the specific context settings.
Do you think it's possible?
-
- 24,544 Posts
It's definitely possible to have a custom cache manager, but I don't think you could set it up to only operate resources in specific contexts. I could be wrong.
-
- 89 Posts
I also have a need for clearing the cache for only the context that te resource is in.
I have setup multiple contexts/websites with contextrouter within one MODX installation.
When I'm developing or managing a contexts/website, it is better to not clear all contexts/websites cache, but just for the context that I'm working on.
I also use CacheMaster, but that isn't fixing this specific problem as you already know...
Is there a solution for this?