GET request sent to REST API only first time in IE

2019-06-08 11:43发布

I've recently started using Restangular for making cross domain requests to a RESTful service, and so far everything works great.

But with IE10 when a make a GET request only for the first time it gets data from the Server, and for subsequent calls it does not hit the server, and returns probably cached data. I need to get the data refreshed from the Server. I tried setting defaultHttpFields cache to false, but no luck. Please help!

Thanks, Lakshmi

2条回答
再贱就再见
2楼-- · 2019-06-08 12:07

I'm the creator of Restangular.

Could you please post an example? If you didn't set the cache to true in defaultHttpfields, Restangular shouldn't cache this at all.

Have you chcked if the requests are going out in the Network tab of the developers console? Does it work in other browsers? Check in restangular Library for RestangularResource to see if it's doing $http call.

Hope it helps!

查看更多
ゆ 、 Hurt°
3楼-- · 2019-06-08 12:19

I just hit this one too. Seems that IE10 is particularly keen on caching results from RESTful calls.

One workaround I used was to just provide some unique value as a parameter to each request and then IE10 seems happy not to cache it. I used the current timestamp in ms since I've seen jQuery use similar workarounds in the past.

    var postsApi = Restangular.all("posts");
    $scope.allPosts = postsApi.getList({ nocache : new Date().getTime() });

Works for now.

查看更多
登录 后发表回答