0

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 1

1

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.

5
  • 1
    that 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.
    – cjbj
    Commented Oct 5, 2016 at 11:39
  • 1
    object 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?
    – Revious
    Commented 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.
    – cjbj
    Commented Oct 6, 2016 at 8:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.