当我使用角度js时如何解决页面缓存问题? [英] How to solve page cache problem when I am using angular js?

查看:128
本文介绍了当我使用角度js时如何解决页面缓存问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



当我使用带有MVC的anguler js时,我正面临网页浏览器缓存问题。

没有变化反映因为页面已经被缓存所以它非常恼火打开一个私人窗户看看变化。



请帮忙。



我有什么试过:



Hi,
I am facing web browser cache problem when I am using anguler js with MVC.
No changes reflect because page is already cached so its very irritating to open a private window to see the changes.

Please help.

What I have tried:

myModule.config(['$httpProvider', function ($httpProvider) {
    $httpProvider.interceptors.push('noCacheInterceptor');
}]).factory('noCacheInterceptor', function () {
    return {
        request: function (config) {
            console.log(config.method);
            console.log(config.url);
            if (config.method == 'GET') {
                var separator = config.url.indexOf('?') === -1 ? '?' : '&';
                config.url = config.url + separator + 'noCache=' + new Date().getTime();
            }
            console.log(config.method);
            console.log(config.url);
            return config;
        }
    };
});

推荐答案

httpProvider', function
httpProvider', function (


httpProvider){
httpProvider) {


httpProvider.interceptors.push(' noCacheInterceptor');
}])。factory(' noCacheInterceptor' function (){
return {
request: function (config){
console .log(config.method);
console .log(config.url);
if (config.method == ' < span class =code-string> GET'
){
var separator = config.url.indexOf(' ?')=== -1?' ?'' &';
config.url = config.url + separator + ' < span class =code-string> noCache =' + new Date ()。的getTime();
}
console .log(config.method);
console .log(config.url);
return config;
}
};
});
httpProvider.interceptors.push('noCacheInterceptor'); }]).factory('noCacheInterceptor', function () { return { request: function (config) { console.log(config.method); console.log(config.url); if (config.method == 'GET') { var separator = config.url.indexOf('?') === -1 ? '?' : '&'; config.url = config.url + separator + 'noCache=' + new Date().getTime(); } console.log(config.method); console.log(config.url); return config; } }; });


这篇关于当我使用角度js时如何解决页面缓存问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆