Avoid overloading admin API

Created on 9 October 2024, 3 months ago

Problem/Motivation

When rendering or loading Cloudinary assets that use the media source the Cloudinary media API is hit multiple times for each individual asset. When loading multiple assets simultaneously this makes a page request very slow and risks hitting the Cloudinary API limits.

Steps to reproduce

  1. Create a cloudinary media type
  2. Use the media type in a content type
  3. Add content with multiple cloudinary media entities

Proposed resolution

There are two main ways the API is hit:

  • Via the CloudinaryAssetHelper::loadAssetByPublicId() method. This is called for nearly every media source attribute, so multiple times for each entity
  • Via Cloudinary::getMetadataAttributes(), which is called once for every media entity that is loaded

To avoid calling the API a caching layer can be added to store assets loaded by public ID. The Cloudinary::getMetadataAttributes() method can use static caching so the meta data attributes are only fetched once each request.

Feature request
Status

Active

Version

3.0

Component

Code

Created by

🇧🇪Belgium klaasvw

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024