Closed remyperona closed 1 month ago
@Tabrisrp Do u know what is the difference between this PR and the code found here: https://github.com/wp-media/imagify-plugin/blob/5684433e2a7d126b312de47ed05d21022483374c/inc/functions/admin.php#L391-L424
Now we inroduce a transient called imagify_user_cache
and there is another one called imagify_user
if it's OK to introduce this transient, should we update the data being saved to have those attributes?
I explained it in the technical description, they're not exactly the same data. One is caching the API call itself, the other is caching the User class.
Ideally we would implement things differently, but it would require too much work right now.
On PR => refresh admin won't send API call to imagify till this transient is expired imagify_check_api_version
On trunk => API call is there with every refresh
Description
Cache the user API call for 5 minutes to avoid the request on each page load.
Type of change
Detailed scenario
develop
, using query monitor, you can see there is a request tohttps://app.imagify.io/api/users/me/
on every page loadTechnical description
Documentation
Following changes made in #899, #900, #902, the
User
class is used on more pages than before, and this class makes an API call to get the user information, with a timeout of 10 seconds.Caching the result of the API call allows to prevent the request on every page.
It was not possible to use the existing
imagify_get_cached_user()
function, because this function returns a cache that doesn't match the result from the API call, but a result from the cache of theUser
class itself.Mandatory Checklist
Code validation
Code style