This particular project is huge, both in data and in user access (personaly I wouldn't use WP but the client wants to).
The problem is, I don't want the front-end to constantly access the database, so is there a way to make WordPress generate a JSON that I can use in the front-end?
I found one called WORDPRESS JSON API, but it doesn't seems to do this, it still access the DB on each request.
This particular project is huge, both in data and in user access (personaly I wouldn't use WP but the client wants to).
The problem is, I don't want the front-end to constantly access the database, so is there a way to make WordPress generate a JSON that I can use in the front-end?
I found one called WORDPRESS JSON API, but it doesn't seems to do this, it still access the DB on each request.
After pondering your question some I am guessing you mean to generate actual physical JSON file in filesystem to use as data source? That would certainly be unorthodox in WP development.
Typically in WP you try to minimize disk access, since it is more likely to be a bottleneck in general. Doing file writes is quite inconvenient in WP extension meant for public distribution, but in private of specific server you could generate and dump JSON into a file rather trivially.
For a more "WordPress way" of doing things you might want to look into persistent Object Cache. WP can be made to use persistent memory cache (such as APC, Memcache, Redis, etc), which both greatly increases its general performance and makes it possible to cache data there via WP APIs.
If you're looking to create a JSON feed from your WordPress site, you should almost certainly be using the REST-API plugin. It's robust, well-documented, and slated for inclusion in WordPress core at some point in the future.
There is a caching plugin available for the REST-API that will cache any JSON output to disk for future requests. Disk caching in WordPress decreases access times by a factor of 10x in my experience, and is worth looking into.
Wordpress REST API is in-built and working already in newer versions of Wordpress.
https://www.codeinwp/blog/wordpress-rest-api/
To access the WordPress REST API, you’ll need to start with the following route:
yoursite/wp-json/wp/v2
or
yoursite/?rest_route=/
json_encode()
it, deliver it to the browser. I really don't see the "problem" you describe though - this is what a database is meant to do. Sticking what could amount to tens to hundreds of megabytes of data into a massive JSON structure in browser memory seems like a bizarre premature "optimization". – bosco Commented Jul 19, 2016 at 18:26