You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been concidering different ways of adding cache support for components in general as there could be need to:
a) cache response for the same request
b) cache response in transient for a short time
For the same request version static variable might be a good solution as the variable scope is more protected than globals but gives a similar flexibility. To keep track of variations of same component you could json encode the $args variable as it should most of the time hold the changing bits of the component (of course there are some "not so dumb" components like hero that uses the context insted of just arguments).
For the generic solution we could either have some reserved arguments like '__cache-transient' => 15 * MINUTE_IN_SECONDS or use PHP7 chaining like Component::transient(['expire' => 3600])::render(['foo' => 'bar]);
So I'd like to fix this issue after implementing a generic solution to caching and in the mean time something like that does work. WP does have some built-in DB caching that might actually prevent doing double DB queries already (would need to be tested) and if there is some kind of page cache in place, this should really cause much issues although not optimal.
Here is my fix:
The text was updated successfully, but these errors were encountered: