Open hochitom opened 9 years ago
Thanks for this issue!
First and foremost, only the REST API infrastructure is being merged into WordPress 4.4. Endpoints are probably coming with 4.5 because they still need need some work. That means we don't need to hurry.
Second, caching REST API requests is not as easy as it seems. There are lots of edge cases that need to be considered.
I'm definitely keeping an eye on this to see how Cachify will fit into the whole picture.
Another thing could be doing it the other way round: I have a node.js app using WP-API and caching the data by itself. I would love to have a unified action from Cachify that would fire each time the cache gets refreshed so that I could trigger a url in the node.js app that would also refresh the cache of the app from the API. Is there a possibility to do this?
Could be a nice feature, because caching is not restricted to WordPress (where it's quite hard), but can be easily implemented in systems that use the API – the only thing that remains is the missing trigger when something is updated in WordPress.
If there isn't already an action for that, we can definitely add one that is being run when the cache gets refreshed. Adding a custom endpoint for that sounds like something other developers should do themselves.
This actions looks like what I was looking for: https://github.com/pluginkollektiv/cachify/blob/master/inc/cachify.class.php#L106 Will give it a try.
In the meantime, the REST-API has been in core for about 3 years now. Is supporting the REST-API still a desired feature?
It's quite simple to support the API by just hooking into the parse_request
action. (needs further checks)
add_action(
'parse_request',
'Cachify::manage_cache',
0
);
Althought is looks so simple it does not make sense to me.
Because Cachify does not support caching for Requests including GET Parameters we can only cache the basic endpoints without any query parameter. Even pagination works via a GET Parameter so we can only cache the first page of every request.
When ever I used the WordPress REST-API, I used at least one GET parameter. So I would never have had the benefit of caching functionality.
For me caching the REST-API without supporting GET Parameters makes no sense.
In fact that wp-api is being merged into wordpress core soon, you should add support for caching wp-api requests as soon as possible.