如何使用PHP或Javascript删除Microsoft Edge的缓存? [英] How to remove Microsoft Edge's cache using PHP or Javascript?
问题描述
我目前已经开始了一个包括AJAX的项目,但遇到了一个问题.使用Microsoft Edge(和Internet Explorer)时,它不会更新数据,除非我关闭整个页面并再次打开它,或者如果我打开PHP文件,然后通过AJAX从中发送数据.
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.
有人没有办法使用PHP和/或Javascript解决此问题吗?
Does anyone no how to solve this issue using PHP and/or Javascript?
预先感谢
推荐答案
快速修复"方法是使用$ .ajax方法的cache:false选项,但这确实不是解决此问题的正确方法问题,如果您可以控制服务器.相反,您应该让php在您不想缓存的服务上返回一个no-cache头,在您想要缓存的服务上返回一个缓存头.
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: How to control web page caching, across all browsers?
否则,您应该具有htaccess,该htaccess指定应缓存哪些文件,例如不经常更改的静态资产(.html,.js,.css等)
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)
这篇关于如何使用PHP或Javascript删除Microsoft Edge的缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!