I'm building a application/game in Codeigniter 3. There is one application running on a beamer in front of a classroom, and other users can play via there mobile. The application needs to send json to the players. It has to be done without any services like Pusher or socket.io, because i can't install anything on the server, and there is no budget for external service.
So i have some Javascript running on the users:
setInterval(function(){
$.getJSON( "ajax/data/json", { 'id': id }, function( data ){
// Do stuff with the data if its available
});
}, 1000);
On the application i have something like this:
public function json()
{
$this->load->model('data_model');
$data = $this->data_model->get_json($this->input->get('id'));
echo json_encode($data);
}
My only worry is the game is played on many locations at the same time. Can i use Codeigniters 'Page Caching' or 'Database Cashing' to prevent too many database requests, and what is the best way to implement this? Or is there any other solution to prevent this?