admin管理员组文章数量:1356371
I'm trying to load a json file using angular (v1.2.6):
$http.get('myfile.json').success(function(data) { ... }
This works fine, except when I create a (static) pressed version of the file on the server, and try to load 'myfile.json.gz' instead (to reduce the loading time).
The request headers seem correct (Chrome 31.0 on Mac) (as stated here and here):
Accept: application/json, text/plain, */*
Accept-Encoding: gzip,deflate,sdch
while the response headers contain:
Connection: close
Accept-Ranges: bytes
Content-Length: 702468
Content-Type: application/x-gzip
Content-Encoding: gzip
However, the content is not automatically depressed by the client browser, as I understand it should be. data.length
is ~700Kb instead of the original unpressed ~3Mb.
Although this one post suggests it needs to be done manually, I understand depression should be automatic and transparent.
My question is, should it be depressed automatically? and why isn't it the case here?
I'm trying to load a json file using angular (v1.2.6):
$http.get('myfile.json').success(function(data) { ... }
This works fine, except when I create a (static) pressed version of the file on the server, and try to load 'myfile.json.gz' instead (to reduce the loading time).
The request headers seem correct (Chrome 31.0 on Mac) (as stated here and here):
Accept: application/json, text/plain, */*
Accept-Encoding: gzip,deflate,sdch
while the response headers contain:
Connection: close
Accept-Ranges: bytes
Content-Length: 702468
Content-Type: application/x-gzip
Content-Encoding: gzip
However, the content is not automatically depressed by the client browser, as I understand it should be. data.length
is ~700Kb instead of the original unpressed ~3Mb.
Although this one post suggests it needs to be done manually, I understand depression should be automatic and transparent.
My question is, should it be depressed automatically? and why isn't it the case here?
Share Improve this question edited May 23, 2017 at 12:32 CommunityBot 11 silver badge asked Dec 31, 2013 at 15:10 Gilles DebunneGilles Debunne 3052 silver badges6 bronze badges1 Answer
Reset to default 6Your content type should not be "application/x-gzip* it should stay : application/json
The content encoding is enough to say to the browser that the content is zipped.
What HTTP server are you running ? You should configure it in order to return the correct mime type, regardless of the .gz extension.
本文标签:
版权声明:本文标题:javascript - No auto-decompression of gzipped json on browser's side when using angular's http get method - Stac 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744016968a2576505.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论