title: Caching REST api using Codeigniter Framework
body: <p>I have two servers. First server is serving as datacenter which only contains database and REST API by philstrgeon <a href="https://github.com/philsturgeon/codeigniter-restserver" rel="nofollow">https://github.com/philsturgeon/codeigniter-restserver</a>.</p>
  
  <p>This first server is basically working with database, I already implemented database cache <a href="http://ellislab.com/codeigniter/user-guide/database/caching.html" rel="nofollow">http://ellislab.com/codeigniter/user-guide/database/caching.html</a>. </p>
  
  <p>Second server, contains frontend which is making requests to first api server and displaying results on site to users. EX: <a href="http://api.server.com/getuses?key=XXXX" rel="nofollow">http://api.server.com/getuses?key=XXXX</a></p>
  
  <p>Problem: As Second server is sending many api requests and first server</p>
  
  <ol>
  <li>Is not fast server like google.</li>
  <li>Contains huge amount of data 2000K rows and expecting more. </li>
  <li>Using multiple MYSQL JOIN query (Almost 5 joins in query).</li>
  </ol>
  
  <p>Second Server taking time:<br>
   &lt;&lt; Page rendered in 6.0492 seconds >> </p>
  
  <p>What I have done and what I am expecting. </p>
  
  <ol>
  <li>I have already indexed and cached MYSQL of first(api) server properly. </li>
  <li>No cache enabled on second server.</li>
  <li>How would I cache api response to second server and will find that there was no change made since last request.</li>
  <li>Would you suggest using some other idea on database like (redis, mongodb etc)?</li>
  </ol>
  
  <p>Any help would be great!!!</p>