<p>Say in my http fileserver, I have <code>/static/foo.tar.gz</code>. Should my fileserver be serving it as <code>/static/foo.tar</code> with <code>content-encoding: gzip</code> always or should it be served as <code>/static/foo.tar.gz</code> with <code>content-type: gzip</code>?</p>
<p>Change <code>foo.tar.gz</code> with any file that ends in <code>.gz</code>. My question boils down to whether or not every <code>.gz</code> file should be served with <code>content-encoding: gzip</code>? I know it's fine for html/css/js but I'm wondering if there are some files, where i should be serving them with <code>content-type: gzip</code>? Why not just always use <code>content-encoding: gzip</code> and strip off the extension?</p>
<hr/>**评论:**<br/><br/>lluad: <pre><p>It's really annoying when I click on a download link for "foo.tar.gz" and the file I end up with is not "foo.tar.gz", it's "foo.tar" or "foo.tar.gz.tar" and it's been transparently gunzipped. I need to re-gzip and rename it to get something close to what I wanted, and if I want to check the hash of the file to ensure I got what I expected I'm out of luck.</p>
<p>You need to distinguish between content that is being transparently gzip compressed to reduce bandwidth, and files that are being downloaded that happen to end in ".gz".</p></pre>nhooyr: <pre><p>Other than wanting to check the hash, why else would you want the .gz file? I think that the hash should be done on "foo.tar", not "foo.tar.gz".</p></pre>sairamk: <pre><p>Its okay to use it with encoding and not have the .gz extension. </p>
<p>For the browser (one type of client), its all about getting the data fast so that it can render faster. </p>
<p>Not all clients accept gzip encoding because bandwidth is okay, but not CPU resources or the capability to unzip to view the content. </p>
<p>For example: command line curl </p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
0 回复
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传