[wp-hackers] Caching as part of the core

Jeff Waugh jdub at bethesignal.org
Sat Jul 28 13:42:58 UTC 2012


On Sat, Jul 28, 2012 at 11:07 PM, Mike Schinkel <mike at newclarity.net> wrote:

> Where is it written on stone that there is an exact purpose for which
> advanced-cache.php is "for?"
>

I invite you to describe a caching-related* use case for which
advanced-cache.php is useful that does not involve page caching.

* I specify caching-related here, only in order to exclude spectacularly
creative and/or incredibly hacky use cases.

> A terminology issue: wp-includes/cache.php is for the most part an object
> > cache *interface* (the implementation of which is only relevant within a
> > single request), while wp-content/object-cache.php is an implementation.
>
> Without an /wp-content/object-cache.php file, /wp-includes/cache.php *is*
> the implementation (WP_Object_Cache() is contained within.)
>

Which you'll see is noted above, with the important caveat: It's only
relevant within a single request.

I invite you to describe a use case for wp-includes/cache.php within the
context of wp-content/advanced-cache.php, noting that it is *not* an
implementation of a persistent object cache. You might have to describe why
using the wp_cache_* functions is preferable to... using variables. Hey, I
like to set a challenge.


> I completely agree with you here. But what I'm saying is that core
> currently doesn't allow us to fully demonstrate for the reasons already
> explained.
>

I'd like you to explain, in technical terms, why you can't build fragment
caching on top of the primitives currently provided by WordPress core. I
don't think this has been "already explained" at all.

Summary:

- advanced-cache.php is, in practice, designed for page caching. You will
only ever want one of those, so a drop-in is fine. It even says so in
wp-settings.php: "For an advanced caching plugin to use. Uses a static
drop-in because you would only want one."

- a persistent object cache implementation will backend the wp_cache_* and
*_transient APIs (which are aggressively used throughout the WordPress code
base), both of which can be used to implement all kinds of caching
strategies at the plugin and theme level (including fragment caching).
There are *possibly* some reasons to consider using multiple persistent
object cache backends, but probably only for layering (request state => APC
=> memcache).


More information about the wp-hackers mailing list