Magnus Vestergaard Magnus Vestergaard - 4 years ago 131
Ajax Question

How to remove Microsoft Edge's cache using PHP or Javascript?

I've currently started on a project including AJAX, and I ran into a problem. When using Microsoft Edge (and Internet Explorer) it won't update data, unless I close the entire page and open it again, or if I open my PHP file, from which I send data through AJAX.

Does anyone no how to solve this issue using PHP and/or Javascript?

Thanks in advance

Answer Source

A "quick fix" would be to use the cache: false option of the $.ajax method, but this really isn't the right way to solve this problem if you have control of the server. Instead, you shoudl have php return a no-cache header on services you don't want cached, and a cache header on services you do want cached.

header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1.
header("Pragma: no-cache"); // HTTP 1.0.
header("Expires: 0"); // Proxies.

The above code was taken from BalusC's answer over here: Making sure a web page is not cached, across all browsers

Otherwise, you should have an htaccess that specifies which files should be cached such as static assets that don't change often (.html, .js, .css, etc)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download