should every .gz file be served with content-encoding gzip?

blov · · 385 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<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&#39;s fine for html/css/js but I&#39;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&#39;s really annoying when I click on a download link for &#34;foo.tar.gz&#34; and the file I end up with is not &#34;foo.tar.gz&#34;, it&#39;s &#34;foo.tar&#34; or &#34;foo.tar.gz.tar&#34; and it&#39;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&#39;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 &#34;.gz&#34;.</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 &#34;foo.tar&#34;, not &#34;foo.tar.gz&#34;.</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

385 次点击  
加入收藏 微博
0 回复
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传