Skip to content

Conversation

@aatanasov-cloudinary
Copy link
Collaborator

@aatanasov-cloudinary aatanasov-cloudinary commented Apr 8, 2025

Improving the update asset paths functionality to deliver better performance on the front-end and when performing WP Rest API requests.

Approach

  • The update and activate asset paths logic was split into two separate methods.
  • The process of updating the asset parent paths happens in these cases:
    • In the WordPress dashboard and the request is not REST API.
    • Using a cron (once a day). This covers manually uploaded plugins/themes.
  • The update process happens before the active one to ensure the activated asset parents are up to date.

QA notes

  • Ensure you have the WP Query Monitor plugin installed.
  • Ensure the Enable additional asset syncing setting is enabled and there are some plugins/themes activated. (screenshot attached below)
  • Go to the WordPress dashboard, and in the WP Query Monitor, filter by Plugin: cloudinary_wordpress and Caller: update_meta_cache(). (screenshot attached below)
  • While you're on the dashboard, there should be update_meta_cache queries that come from Cloudinary\Assets->update_asset_paths() as shown in the screenshot below.
  • Go to the Front-end, update_meta_cache from Cloudinary\Assets->update_asset_paths() shouldn't appear.
  • Testing Utils::is_rest_api() can happen by using a REST API request as this one wp-json/wp/v2/posts/?_envelope&_wpnonce=<nonce> -- the nonce can be got from wp-admin/admin-ajax.php?action=rest-nonce -- more info here.

Enabled asset syncing
asset-syncing

Postmeta queries
postmeta-queries-update

@aatanasov-cloudinary aatanasov-cloudinary marked this pull request as ready for review April 8, 2025 08:49
Copy link
Contributor

@tharsheblows tharsheblows left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@aatanasov-cloudinary aatanasov-cloudinary merged commit 7b9e812 into develop Apr 15, 2025
4 checks passed
@aatanasov-cloudinary aatanasov-cloudinary deleted the fix/rest-api-calls-number branch May 19, 2025 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants