Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PL admin performance can be improved #1015

Closed
thelovekesh opened this issue Feb 26, 2024 · 4 comments · Fixed by #1022
Closed

PL admin performance can be improved #1015

thelovekesh opened this issue Feb 26, 2024 · 4 comments · Fixed by #1022
Assignees

Comments

@thelovekesh
Copy link
Member

Summary

PL plugin is using plugins_api() to retrieve the data of the standalone plugin from the WPOrg API.

$plugin = plugins_api(
'plugin_information',
array(
'slug' => $plugin_slug,
'fields' => array(
'short_description' => true,
'icons' => true,
),
)
);

Currently, when a user loads the admin page it gets fired to retrieve the data of each available plugin:

performance/load.php

Lines 336 to 342 in 0f110ff

return array(
'webp-uploads' => 'WEBP_UPLOADS_VERSION',
'dominant-color-images' => 'DOMINANT_COLOR_IMAGES_VERSION',
'performant-translations' => 'PERFORMANT_TRANSLATIONS_VERSION',
'auto-sizes' => 'IMAGE_AUTO_SIZES_VERSION',
'speculation-rules' => 'SPECULATION_RULES_VERSION',
);

Even when the data is retrieved for all plugins, it gets fired again when the user saves the settings or loads the page, and hence page loading time increases.

To avoid hitting the WPOrg API multiple times and reduce the page load time second time onwards, we should consider caching the plugin information for a day or so in the:

  • Object cache if present.
  • Else, save the response data as transients.
@thelovekesh thelovekesh self-assigned this Feb 26, 2024
@westonruter
Copy link
Member

It makes sense to store the plugin info in a transient period. (Remember that when external object cache is enabled then transients are stored on object cache.) Just need to make sure that the cache is varied by the plugins it is fetching or else to vary by the Performance Lab plugin version, so that when a new version is released we will get any new plugins showing up right away.

As for the transient max age, a day may be excessive. Even just 10 minutes would suffice, right? Granted, the information wouldn't be changing often, and if it does, it's likely to coincide with a new PL plugin release anyway. So in that case, an even longer TTL would be fine.

@thelovekesh
Copy link
Member Author

@westonruter Since we are fetching data for standalone plugins, do we need to vary its cache by PL plugin version? I think we can simply store it for some time and vary the cache by standalone plugin name.

@westonruter
Copy link
Member

Storing it for a set period of time (e.g. 1 day) would be fine.

Why vary the cache by the standalone plugins name?

@westonruter
Copy link
Member

Oh, because each plugin is queried separately.

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 a pull request may close this issue.

2 participants