当能,文本压缩后会降低gzip的压缩效率,所以,当服务器端启用了gzip压缩支持的话,文本压缩就多余了。
不过开启服务器端压缩也是需要占用系统资源的。
JSIntegration(JSPackager) 脚本管理框架,专注于无侵入的脚本管理。
http://www.xidea.org
http://forum.xidea.org
HTTP 1.0 协议制定的时候,已经充分考虑了您的建议
在 web server 和 browser 之间可以通过压缩数据的方式进行通讯,例如给webserver发送一个这样的请求封包:
GET url HTTP/1.0
Accept-Encoding: gzip,deflate
...
如果 web server 支持 gzip 压缩编码的话,就会将Http Response body 的内容进行压缩后返回给客户端,浏览器会自动解压还原内容,这个过程对web应用层面是透明的。web应用层面的开发人员不必关心这个过程。 IIS 和 apache 都支持这种方式。通过简单的配置就可以实现了。
附 RFC1945 3.5 节内容
3.5 内容译码(Content Codings)
内容译码值用于指示对资源进行的编码转换。内容译码主要用于将经过压缩、加密等操作的文件进行还原,使其保持其原来的介质类型。典型情况下,经过编码保存的资源只能经过解码或类似的操作才能还原。
content-coding = "x-gzip" | "x-compress" | token
注意:出于对未来兼容性的考虑,HTTP/1.0应用应将"gzip" 和"compress" 分别与 "x-gzip"和"x-compress"对应起来。
所有的内容译码值都是大小写敏感的。HTTP/1.0在内容编码(10.3节)头域中使用内容译码值。虽然该值描述的是内容译码,但更为重要的是,它指明了应当用什么机制来进行解码。注意,单独的程序可能有能力实现对多种格式编码的解码。
在这段文字中,提到了两个值:
x-gzip
文件压缩程序"gzip" (GNU zip,由Jean-loup Gailly开发)的编码格式。该格式属于典型的带有32位CRC 校验的Lempel-Ziv译码 (LZ77)。
x-compress
文件压缩程序"compress"的编码格式,该格式适用于LZW(Lempel-Ziv-Welch)译码。
注意:用程序名来标识编码格式的做法不是很理想,在将来可能不会继续这样做。现在之所以这样做是出于历史的原因,并非良好的设计。
--- e文原文 ---
3.5 Content Codings
Content coding values are used to indicate an encoding transformation
that has been applied to a resource. Content codings are primarily
used to allow a document to be compressed or encrypted without losing
the identity of its underlying media type. Typically, the resource is
stored in this encoding and only decoded before rendering or
analogous usage.
content-coding = "x-gzip" | "x-compress" | token
Note: For future compatibility, HTTP/1.0 applications should
consider "gzip" and "compress" to be equivalent to "x-gzip"
and "x-compress", respectively.
All content-coding values are case-insensitive. HTTP/1.0 uses
content-coding values in the Content-Encoding (Section 10.3) header
field. Although the value describes the content-coding, what is more
important is that it indicates what decoding mechanism will be
required to remove the encoding. Note that a single program may be
capable of decoding multiple content-coding formats. Two values are
defined by this specification:
x-gzip
An encoding format produced by the file compression program
"gzip" (GNU zip) developed by Jean-loup Gailly. This format is
typically a Lempel-Ziv coding (LZ77) with a 32 bit CRC.
x-compress
The encoding format produced by the file compression program
"compress". This format is an adaptive Lempel-Ziv-Welch coding
(LZW).
Note: Use of program names for the identification of
encoding formats is not desirable and should be discouraged
for future encodings. Their use here is representative of
historical practice, not good design.