-
Notifications
You must be signed in to change notification settings - Fork 27
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
Cache user API call for 5 minutes #907
Conversation
@Tabrisrp imagify-plugin/inc/functions/admin.php Lines 391 to 424 in 5684433
Now we inroduce a transient called if it's OK to introduce this transient, should we update the data being saved to have those attributes? imagify-plugin/inc/functions/admin.php Lines 414 to 415 in 5684433
|
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 |
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