Can caching plugins (like w3 Total Cache or similar) force themes and plugins to use cache for every object instantiated? Or are they just optimizing plain WordPress.
1 Answer
No, they can't. Caching plugins cannot possibly know how plugins and themes work internally. They store whole html pages and detect some changes to determine whether a page needs refreshing.
Suppose they would able to analyse all code running and cache every time an object is initiated. Not only would that process itself cost a lot of computing time, many objects would be cached pointlessly, because they are used only once anyway. And the result is cached as part of the page.
Some objects that return on avery page (menus, widgets) might benefit from caching, but you would need deep insight in a theme to see whether a menu is the same on every page or if there maybe is a filter somewhere that changes it.
-
1that is just wrong. as long as plugins and themes use the core API they will benefit from object caching and there is no explicit opt-in required. Guess the question here is which objects the OP refers to. Commented Oct 5, 2016 at 11:19
-
@MarkKaplun Built-in caching only lasts for one page load. W3TC offers some object caching, but really not for every object as OP asks.– cjbjCommented Oct 5, 2016 at 11:39
-
1object caching works for all important core APIs. The only way you will not hit object cache in a theme/plugin is if you try to directly access the DB with SQL statements Commented Oct 5, 2016 at 11:52
-
Is it possible to see how many things us caching? I.e. through query monitor or similar?– ReviousCommented Oct 6, 2016 at 8:19
-
1@Revious All objects created through the normal WP API are cached, but only for the duration of one page load. Caching plugins take some objects and remember them for a longer time, but this depends on the plugin, so there is no general tool to know what is cached and what is not.– cjbjCommented Oct 6, 2016 at 8:22