相关疑难解决方法(0)

更好的方法来防止AngularJS中的IE缓存?

我目前使用service/$ resource来进行ajax调用(在这种情况下为GET),并且IE缓存调用以便无法从服务器检索新数据.我使用了一种技术,我通过谷歌搜索创建一个随机数并将其附加到请求,以便IE不会去缓存数据.

有没有比将cacheKill添加到每个请求更好的方法?

工厂代码

.factory('UserDeviceService', function ($resource) {

        return $resource('/users/:dest', {}, {
            query: {method: 'GET', params: {dest: "getDevicesByUserID"}, isArray: true }
        });
Run Code Online (Sandbox Code Playgroud)

来自控制器的呼叫

$scope.getUserDevices = function () {
        UserDeviceService.query({cacheKill: new Date().getTime()},function (data) {
            //logic
        });
    }
Run Code Online (Sandbox Code Playgroud)

caching angularjs

60
推荐指数
5
解决办法
6万
查看次数

标签 统计

angularjs ×1

caching ×1