简体   繁体   English

使用Ajax Minfy工具压缩文件

[英]Gzipping file using Ajax Minfy tool

我想知道是否也可以使用Ajax Minfy工具进行G Zip。转换过程中运行命令行工具时,它显示了压缩的百分比,可以压缩多少,但实际上并没有压缩,它只是压缩..那么可以使用此工具http://ajaxmin.codeplex.com进行G Zip

The gzip compression should be done by the server, as the server knows whether the client is able to decompress the data. gzip压缩应由服务器完成,因为服务器知道客户端是否能够解压缩数据。 If properly configured the webserver will handle it transparently for you. 如果配置正确,Web服务器将为您透明地处理它。

In lighttpd you can enable compression like this: 在lighttpd中,您可以启用以下压缩:

server.modules += ( "mod_compress" )

compress.cache-dir = "/var/cache/lighttpd/compress/" # change this as you want
compress.filetype = ( 
    "application/x-javascript",
    "application/javascript",
    "text/javascript",
    "text/css",
    "text/html",
    "text/plain"
)

for further information see ModCompress in the lighttpd manual . 有关更多信息,请参见lighttpd手册中的ModCompress

gzip-ing is done at the server side, this can be done in a number of ways: gzip-ing是在服务器端完成的,可以通过多种方式完成:

  1. Automatically using your server software (see the documentation for your web server software). 自动使用服务器软件(请参阅Web服务器软件的文档)。
  2. Using a server side script, for example the PHP one below: 使用服务器端脚本,例如下面的PHP:

     <?php header("Content-Encoding: gzip"); echo gzencode($file_contents, 9); ?> 

This PHP example first sets the gzip content encoding header, this instructs the browser to decompress the response and then outputs the encoded file contents (using a high compression level set at 9). 此PHP示例首先设置gzip内容编码标头,这指示浏览器解压缩响应,然后输出编码的文件内容(使用设置为9的高压缩级别)。 For more info see the PHP documentation on gzip . 有关更多信息,请参见gzip上PHP文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM