AngularJS $ http.get()最多需要10-20秒在Chrome,Firefox中工作正常

问题描述:

我遇到与AngularJS /谷歌浏览器一个奇怪的错误。当我做了$ http.get()它需要长达18秒,实际完成之前。这似乎在保持待定的选项的方法:

I'm encountering an odd error with AngularJS / Google Chrome. When I do an $http.get() it takes up to 18 seconds before it actually completes. It seems to keep at "PENDING" for the "OPTIONS" method:

http://i.imgur.com/yEozFdm.png

这是服务于网页服务器是猫鼬,一个@本地:5000瓶,谁为了使CORS工作返回下面的标题

The server that serves the pages is Mongoose, the one @ localhost:5000 is Flask, who returns the following headers in order for the CORS to work.

@mod.after_request
def after_request(response):
    response.headers.add('Access-Control-Allow-Origin', 'http://localhost:8080')
    response.headers.add('Access-Control-Allow-Methods', 'GET, POST, OPTIONS')
    response.headers.add('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type,     Accept')

任何人都知道为什么Chrome的延迟OPTIONS请求? (从烧瓶服务器调试控制台,似乎在页面重新加载后OPTIONS方法真的只有到达10-20秒)。它似乎工作在Firefox罚款。

Anyone knows why Chrome is delaying the OPTIONS request? (From the flask server debug console, it seems that the OPTIONS method really only arrives 10-20 seconds after the page has been reloaded). It seems to work fine in Firefox.

这似乎已经解决了,一旦我禁用了predict网络操作,以提高网页加载速度选项。很奇怪,也许我应该离开这个问题打开,如果有人可以给一个可能的原因是什么?

It seems to have been solved once I disabled the "Predict network actions to improve page load performance" option. Very odd, perhaps I should leave this question open for if someone could give a possible reason for this?

编辑:见的原因意见