$ http的Angular IE缓存问题$ http的Angular IE缓存问题从IE发送的所有ajax调用都由Angular缓存,我得到一个304 response用于所有后续调用。虽然请求是相同的,但在我的情况下,回复并不相同。我想禁用此缓存。我尝试添加cache attribute到$ http.get但仍然没有帮助。如何解决这个问题?
3 回答
森栏
TA贡献1810条经验 获得超5个赞
我没有为每个单个GET请求禁用缓存,而是在$ httpProvider中全局禁用它:
myModule.config(['$httpProvider', function($httpProvider) {
//initialize get if not there
if (!$httpProvider.defaults.headers.get) {
$httpProvider.defaults.headers.get = {};
}
// Answer edited to include suggestions from comments
// because previous version of code introduced browser-related errors
//disable IE ajax request caching
$httpProvider.defaults.headers.get['If-Modified-Since'] = 'Mon, 26 Jul 1997 05:00:00 GMT';
// extra
$httpProvider.defaults.headers.get['Cache-Control'] = 'no-cache';
$httpProvider.defaults.headers.get['Pragma'] = 'no-cache';}]);添加回答
举报
0/150
提交
取消
