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 upto date information.
thanks in advance
On the General tab, locate the Browsing history section, and click Settings. On the Temporary Internet Files tab, confirm that Every time I visit the webpage is selected. On the Caches and databases tab, confirm that Allow website caches and databases is not selected. Click OK.
In general, most modern browsers will cache JavaScript files. This is standard practice for modern browsers and ensures an optimized loading experience. Cached assets such as JavaScript will typically be served from the browser's cache instead of making another request for a resource that has already been retrieved.
In Internet Explorer, select the Tools button, point to Safety, and then select Delete browsing history. Select the Cookies and website data check box, and then select Delete.
ajax, which will allow you to turn caching off: $. ajax({url: "myurl", success: myCallback, cache: false});
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With