[wp-trac] [WordPress Trac] #14759: Improve the way oEmbed deals with caching

WordPress Trac noreply at wordpress.org
Wed Mar 13 22:41:33 UTC 2013


#14759: Improve the way oEmbed deals with caching
--------------------------+-----------------------------
 Reporter:  Viper007Bond  |       Owner:
     Type:  enhancement   |      Status:  new
 Priority:  normal        |   Milestone:  Future Release
Component:  Embeds        |     Version:  3.0.1
 Severity:  normal        |  Resolution:
 Keywords:                |
--------------------------+-----------------------------

Comment (by leewillis77):

 I posted a patch to #23763 with the main aim of supporting cache_age in
 oEmbed responses, but it seems there's a lot of crossover with this bug so
 I've closed that in favour of this. Details and patch copied below:

 Currently oEmbed results are cached permanently in the postmeta table.
 These cached results never expire, and will be used forever, or until the
 WordPress post is updated. This is reasonable behaviour for resources that
 do not specify a cache_age - although I'd argue we should re-check the
 oEmbed source occassionally to cope with the case where the original
 resource is updated / removed etc.

 The oEmbed documentation (​http://oembed.com/ - section 2.3.4) lists
 cache_age as optional - so providers may not provide one. If it is
 provided, consumers still aren't bound to honour it ("Consumers may choose
 to use this value or not.") - so the current behaviour is perfectly in
 line with the spec, but I believe we can do better.

 Several of the currently accepted oEmbed providers provide cache_ages
 (E.g. flickr, hulu, and twitter). Allowing cache_ages also helps when
 embedding information that can change over time (See
 http://wordpress.org/extend/plugins/github-embed/ and
 http://wordpress.org/extend/plugins/wporg-plugin-embed/ for example).

 Patch to follow which:

 - Moves the caching of oEmbed responses from class-wp-embed.php down into
 class-oembed.php where it has access to the oEmbed response
 - Caches oEmbed HTML in transients rather than postmeta (The same embedded
 resource will be used no matter which post it is embedded in)
 - Sets a default cache period of 12 hours for oEmbed failures
 - Sets a default cache period of 30 days if no cache_age is specified
 - Sets a cache period according to cache_age if it is specified
 - Adds a new third argument to WP_oEmbed->get_html() and wp_oembed_get()
 to pass the value of $usecache through from classs-wp-embed.php

 More than happy to work this patch up as needed, I'm aware there's still
 some stuff to tidy up with respect to clearing out the functions that
 currently drop the postmeta on save/update etc. I'd like to get agreement
 on the broad approach first though to save duplication of effort.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/14759#comment:15>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list