craft-videoembedder
craft-videoembedder copied to clipboard
Super slow when using 5 embeds
Hi there,
First of all: Awesome plugin!
I'm running against a little(big) problem, when using 6 embeds at once, it becomes very very slow in loading the webpage. Even when i'm trying to only show the youtube Thumbnails.
I can't lay my finger on the way this plugin gets the Thumbnail URL.
Try caching your results? The plugin uses another PHP library to return everything. Essentially the plugin is just a wrapper for that library. Here is the function called for getting the thumbnail: https://github.com/oscarotero/Embed/blob/c8e1514861e7880f31e84b2c883bf31cff3e182a/src/Adapters/Adapter.php#L468
Caching is not really a solution. The underlying problem is that when VideoEmbedderService->getInfo
is called new Embed::create
is called and that causes a new HTTP request.
A single youtube embed (with poster image) causes 10 (!) HTTP requests to the youtube domain.
Simple per request caching brings this back to only 2 (with something like $this->infoCache[$url]
).
I will probably drop a pull request later.
I tried @renzo-s code in the linked file but it doesn't seem to load the videos.
Try caching your results? The plugin uses another PHP library to return everything. Essentially the plugin is just a wrapper for that library. Here is the function called for getting the thumbnail: https://github.com/oscarotero/Embed/blob/c8e1514861e7880f31e84b2c883bf31cff3e182a/src/Adapters/Adapter.php#L468
Thanks, this is speeding up things again!
@renzo-s I'm calling the getVideoThumbnail function, the cache tag around this is a major improvement, it just returns a URL, can't seem to track down the 2 requests you mentioning.
Was there an end-solution for this? Assume if we use the @renzo-s solution, we'd need to change the core files?
We have this fix in production for over a year without problems. If this is an issue for you @terryupton, and this repo seems dead, you can always install my fork, but I'm not actively developing that one either.