WordPress / wporg-theme-directory

12 stars 6 forks source link

API: Avoid multiple concurrent wp-themes requests #144

Open dd32 opened 3 weeks ago

dd32 commented 3 weeks ago

The code for fetching Patterns and Style variations from wp-themes attempts to avoid issues during outages, but doesn't make any effort to lock the request, to avoid many queries hitting wp-themes.com at the same time when the transient isn't set.

This PR simply sets the short transient before making the HTTP request, ensuring that only a single request is being processed against wp-themes.com at any time.

This could be enhanced in general by..

ryelle commented 3 weeks ago

Not calling this at use-time in the theme, but rather, from the update wp-themes.com deployed theme version handler (wporg_themes_update_wpthemescom()) and caching it against the Theme Post in post_meta.

This idea makes sense to me, the patterns/variations can't change without a theme update, so caching it then would be smart, and would avoid the render-time API calls.