[wp-trac] [WordPress Trac] #23763: Respect cache_age in oEmbed requests

WordPress Trac noreply at wordpress.org
Wed Mar 13 22:29:37 UTC 2013


#23763: Respect cache_age in oEmbed requests
-----------------------------+-------------------------
 Reporter:  leewillis77      |       Type:  enhancement
   Status:  new              |   Priority:  normal
Milestone:  Awaiting Review  |  Component:  Embeds
  Version:  3.5.1            |   Severity:  normal
 Keywords:  has-patch        |
-----------------------------+-------------------------
 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

 Open to discussion about the implementation details.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/23763>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list