Gzipped JSON file not decompressing

前端 未结 3 888
天命终不由人
天命终不由人 2020-12-15 19:43

I have large (30MB+) JSON files stored on my server as file.json. Using jQuery\'s getJSON(\"http://site/file.json\") function it works just fine. But, as you\'d probably thi

3条回答
  •  别那么骄傲
    2020-12-15 20:50

    You would not have to manually gzip the file on server. If the browser and hence underlying XMLHttpObject supports Accept-Encoding gzip, deflate header then the file (response) will be zipped (deflated) by server before transmission.

    However you need to configure your webserver (if using IIS, please check its metabase.xml) to apply deflate on response, as per incoming HTTP request's header.

    Configuration Help:

    For Apache web server refer : http://httpd.apache.org/docs/2.0/mod/mod_deflate.html

    For IIS : http://www.codinghorror.com/blog/2004/08/http-compression-and-iis-6-0.html

提交回复
热议问题