I’m using WordPress and use the API data with JSON format from a source for my site content, for example: http://api.source.com/data.json
But loading of my site take a bit longer because every time the page loaded will always take and read the file from the source, the question is how can I store the JSON file to WordPress directory and automatically update it every 12 hours?
Sorry for bad English but hope you got my point, Please help!
There are multiple options.
Use memcache -> Store the retreived json in memcache, and expire it after every 12 hours. This would be the fastest lookup.
http://www.php.net/manual/en/memcache.examples-overview.php
Database -> Store the retreived json in a database table with a key, you can use varchar , text , or blob datatype based on size of your json.
Write to a file -> Write the json to a text file in any of your directory which has write permissions,and read it from there.
http://php.net/manual/en/function.file-put-contents.php