AngularJS "caching" 网速较慢 :(

AngularJS "caching" on slow internet connection :(

我有一个简单的 angularjs 应用程序,例如:

module = angular.module 'testFooBarModule', ['ngResource']

module.factory 'FooBar', ($resource)->
    $resource 'foobar/target', {},
        load:
            method: 'GET'
            cache: false # no effect
            headers: 
                'Cache-Control': 'no-cache' # no effect

module.controller 'FooBarCtrl', ($scope, FooBar)->
    FooBar.load (result)->
        console.log result

使用家庭 wlan 或移动 hspa 等高速互联网一切正常。请求已触发,服务器给了我一个唯一的响应。 但是对于像 edge 或 gprs 这样的 2G 互联网,服务器没有收到任何请求,angularjs 应用程序总是给我相同的结果。没有错误发生。 "no-cache" header 也已发送。

我不知道出了什么问题。谁能帮帮我?

对不起我的英语:D

此致。

这可能不是 angular 问题。我的猜测是 internet-provider 正在做一些魔术 http-proxying 来保护带宽,或者您的底层 OS 正在尝试为您缓存它。

部分选项:

  • 使用 HTTPS 应该会阻止提供商 man-in-the-middles 并且对于移动应用来说无论如何都是个好主意!
  • 使用像时间戳这样笨拙的动态参数
  • 使用 POST 或 PUT 作为动词
  • 在 server-response 中添加 'Cache-Control: no-cache' header,我认为这是 most-clean 解决方案