wrav / oembed

A simple plugin to extract media information from websites, like youtube videos, twitter statuses or blog articles.
MIT License
37 stars 37 forks source link

Slow Twig Rendering Times #16

Closed mattrothenberg closed 5 years ago

mattrothenberg commented 5 years ago

Howdy!

I've noticed a trend where entries on my site that are using embed fields inside of a matrix block are taking a very long time to load. Here's a screenshot, for example, of a nearly 8 second render time for an article with a single embed of a CNN video.

Screen Shot 2019-08-04 at 10 28 31 PM

These slow rendering times seem pretty deterministic. The only solution I've found has been to cache the article itself, which definitely helps.

I'm curious, though, whether you can think of any opportunities for optimization here on the PHP/Twig side of things.

One thing that would be cool, too, is if users could pass a custom class to the iframe that gets rendered by Twig, e.g., lazyload if you're using the lazysizes plugin, as well as being able to specify data-src instead of src.

Any ideas would be greatly appreciated!

reganlawton commented 5 years ago

@mattrothenberg Hmm are you able the link your using? I had an update in v1.1.6 , which made caching on the oEmbed side an optional feature, previously was always enabled.

This might be the issue your running into, as the plugin does offer support to cache the record on the PHP side.

mattrothenberg commented 5 years ago

Oooh, I totally missed that in the changelog.

For example, here are two pages that were super slow to render prior to using the %cache% tag.

  1. https://passivehouseaccelerator.com/articles/passive-without-compromise-passive-house-design-improving-architectural-practice
  2. https://passivehouseaccelerator.com/articles/cnn-covers-passive-house-these-100-year-old-homes-are-on-the-cutting-edge-of-energy-efficiency
reganlawton commented 5 years ago

That might be your servers networking. It loaded decently fine for me if you use the caching option id should be cached from the time you load the URL in the CMS admin area.

mattrothenberg commented 5 years ago

Roger that. Seeing as it's entries with embeds that are consistently the slowest to load, I think it's less a question of overall networking.

Both of those pages had been cached for at least a few days now, hence the fast load time. Will give that option a try.

Thanks for the prompt response!

On Sun, Aug 4, 2019, 11:41 PM Regan Lawton notifications@github.com wrote:

That might be your servers networking. It loaded decently fine for me if you use the caching option id should be cached from the time you load the URL in the CMS admin area.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/wrav/oembed/issues/16?email_source=notifications&email_token=ABHI7NANBSWCLEGU7N6VY7DQC6OPVA5CNFSM4IJG6HK2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3QTCEA#issuecomment-518074640, or mute the thread https://github.com/notifications/unsubscribe-auth/ABHI7NEAHBQL6OX73G642KLQC6OPVANCNFSM4IJG6HKQ .

spoeken commented 7 months ago

Hey @mattrothenberg , did you find a solution to this? Or an explanation why its slow?

mattrothenberg commented 7 months ago

@spoeken Sorry, I have no recollection of working on this 🙈

spoeken commented 7 months ago

@mattrothenberg haha, ok 😄 thank you