Closed reefdog closed 9 years ago
Gosh, WP oEmbed caching is a mess. After testing and searching the source, here's what I've determined:
wp_oembed_get()
is uncached, so every pageload hits us twice: once for the oEmbed service and then once for the resource data.
$wp_embed->shortcode()
trick suggested by a WP employee here caches the result of the oEmbed call in the postmeta
table, ostensibly with a 24-hour cache age. Except…
cache_age
is completely ignored, despite conversation in that ticket around supporting it.So, it seems we must decide between:
I vote for #2, partly because I don't believe my own results and have to assume the cache would eventually expire, and partly because stale embed codes are less of a problem than letting WP DDOS us.
That sounds... awful?
Remember that this is just for the oembed response... and since our embed codes are normally static anyway... So what i'd say is we should cache as aggressively as possible, and any data changes that are made will be handled through our platform caching & expiry anyway.
Yup.
I think caching the embed code is probably fine. Every raw embed in the wild is essentially the same thing. As long as the underlying document keeps getting fetched, it shouldn't be a problem.
But I concur with Ted: Ick.
WP can cache the oEmbed response; to enable it, we just need to flip
WP_DocumentCloud::CACHING_ENABLED
to true. But does it obey ourcache_age
or have its own internal age? Research.