Friday, March 29, 2013

disable cache on html5 application

I have developed an android application which continuously get update from a server through AJAX call and there is a PHP file on the server which respond to the AJAX request. My application working properly in localhost. But after i install the application on my android phone, First two or three updates are successfully happens and then after it gives me the historical value( not update).

The problem is the cache. Application hold values on cache and give the cache data when request through AJAX.

I fixed this problem by simply added few codes on the top of my server side PHP file fro disabling the cache. Below is the code.


header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");

0 comments:

Post a Comment