Automattic / jetpack

Security, performance, marketing, and design tools — Jetpack is made by WordPress experts to make WP sites safer and faster, and help you grow your traffic.
https://jetpack.com/
Other
1.59k stars 798 forks source link

Jetpack slows site by 400ms when there is an Instagram url #8846

Open lucalooz opened 6 years ago

lucalooz commented 6 years ago

We are seeing a slow down of 400ms when we enable Jetpack on posts that contains an Instagram url.

This seems to be caused by the Jetpack automatic embed for Instagram https://github.com/Automattic/jetpack/blob/e4477ebb9e13752a04776421351b7809039baf10/modules/shortcodes/instagram.php#L65 It does an http request to the oembed Instagram api and uses the WP Object Cache to cache the results. However by default the WP Object Cache is valid only for the executing request unless you add a persistent storage (apcu, memcached, redis etc).

The default WP Core oembed implementation uses the database postmeta to cache oembed results and this issue doesn't happen. https://github.com/WordPress/WordPress/blob/5d1e06f93925e23ddec79e643d4ce4c963d46f14/wp-includes/class-wp-embed.php#L276

Is there a specific reason for which Jetpack replaces the default oembed core implementation? Why the Jetpack implementation uses WP Object Cache and not postmeta like wp core for caching?

pmciano commented 6 years ago

Not sure if this is related, but we did get another report of this in the forums, but with an up to 20 second delay. I was not able to replicate this issue on a test site.

stale[bot] commented 5 years ago

This issue has been marked as stale. This happened because:

No further action is needed. But it's worth checking if this ticket has clear reproduction steps and it is still reproducible. Feel free to close this issue if you think it's not valid anymore — if you do, please add a brief explanation.

jeherve commented 5 years ago

Related: #11063

stale[bot] commented 5 years ago

This issue has been marked as stale. This happened because:

No further action is needed. But it's worth checking if this ticket has clear reproduction steps and it is still reproducible. Feel free to close this issue if you think it's not valid anymore — if you do, please add a brief explanation.