$doc->clearCache(); probably only deletes the corresponding file in core/cache/resource. But there is additional information in core/cache/context_settings (like “aliasMap”, “resourceMap”) that also has to be updated.
oh, thank you.
is it possible to refersh only for this resource?
Because if there are many new resources created every time all cache is cleared. So, the performance of whole website then suffers…
Well, I’m not an expert. But as far as I can tell, the information in core/cache/context_settings is an aggregate of the whole context information. So you probably have to clear at least the data from the context the new resource is in, if just calling $doc->clearCache(); doesn’t work.
Also, it’s worth checking if getPage/getResources internally caches the data. Maybe it’s enough to just clear that cache.
The CacheMaster extra will clear the cache for just one resource when you save it rather than clearing the whole cache.
Be aware, though that just clearing the resource cache might not be enough, because the cache for TVs and other things might also need clearing when the resource changes.
I saw, that not the cache of the special resource was the problem.
I think the problem was the aliasmap cache.
Is it possible to add the specific entry to this cache for better performance?
Just a quick add on to this, you can unlink() a specific cache file programmatically since all the cached resources are saved with the same nomenclature in the same place (this location changed in v3, so updating your site would require a script change). In v2 the path is core/cache/resource/[context]/resources/[id].cache.php so you could, as an example:
Of course, this will not clear any navigation or stored lists this resource might appear in, but it will remove that specific resource cache and force it to refresh on the next view.