I have an php powered application with javascript and many jax calls. my application is working upto date in firefox. but when i run it in internet explorer-8 or similar versions my ajax call gets cached in my browser so i am not able to output the upto date info with the ajax calls instead the result for that ajax calls are served with old data's which reside in the browser cache.
I have tried lots of possible options as listed below
1.) I added following meta tag in header files
<meta http-equiv='cache-control' content='no-cache'>
<meta http-equiv='expires' content='0'>
<meta http-equiv='pragma' content='no-cache'>
2.)I added Following php code
header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Pragma: no-cache');
But still the above 2 approaches did not solve my problem ie, please can anybody help me to disable caching internet explorer when my application runs, so that its possible to get u开发者_如何学Cpto date information.
thanks in advance
Make each AJAX request unique in some way. That will prevent IE from caching the response.
For example, if your normal AJAX query URL is www.mysite.com/ajax.php?dog=cat, add in a querystring parameter to each AJAX request that is unique:
www.mysite.com/ajax.php?dog=cat&queryid=1
Increment that parameter each time you make an AJAX request, and that should hopefully do the trick for you.
精彩评论