wp-media / imagify-plugin

Speed up your website with lighter images without losing quality.
https://imagify.io
73 stars 26 forks source link

Reduce the number of calls to Imagify API users/me #923

Open MathieuLamiot opened 2 days ago

MathieuLamiot commented 2 days ago

Context 2.2.3 introduced a call for user data on all admin pages. As a result, we perform calls to the Imagify API users/me much more often. However, the data from the API is not directly required on all admin pages, but rather on bulk & setting pages, as well as when opening the Imagify admin bar (which is on all admin pages). A mitigation has been set with a response cache of 5 minutes with the transient imagify_user_cache. However, the number of calls to the API remains high overall, and further increasing the transient TTL would disrupt the freshness of the data as explained here.

Expected behavior Highly reduce the number of calls to Imagify API users/me overall. Ideally, as explained here, we should perform calls to the API only when really needed (bulk & settings pages, or when hovering the Imagify admin bar) and combine this with some caching for a short amount of time (as already done). If this is not possible, other alternatives can be considered such as a longer cache time but providing a refresh button. See the discussion here

Acceptance Criteria The main acceptance criteria is that the number of calls to the Imagify App must be reduced overall. Exact ACs will depend on the approach selected (request only when needed or longer cache + refresh).

For "request only when needed":

For "longer cach + refresh".