对于LAMP服务器提供的html、css和javascript文件,这两种方法都有什么好处?有没有更好的选择?

服务器使用Json向地图应用程序提供信息,因此需要大量的小文件。

是否有任何性能打击涉及选择gzip而不是deflate的http压缩?


当前回答

Mod_deflate需要更少的服务器资源,尽管您可能会在压缩量方面付出一些代价。

如果您正在处理许多小文件,我建议您对压缩和未压缩的解决方案进行基准测试和负载测试——您可能会发现在某些情况下启用压缩并不能节省成本。

其他回答

主要原因是deflate的编码速度比gzip快,而且在繁忙的服务器上,这可能会产生不同。对于静态页面,这是一个不同的问题,因为它们可以很容易地预压缩一次。

如果我没记错的话

Gzip将压缩比deflate多一点 通缩更有效

There shouldn't be any difference in gzip & deflate for decompression. Gzip is just deflate with a few dozen byte header wrapped around it including a checksum. The checksum is the reason for the slower compression. However when you're precompressing zillions of files you want those checksums as a sanity check in your filesystem. In addition you can utilize commandline tools to get stats on the file. For our site we are precompressing a ton of static data (the entire open directory, 13,000 games, autocomplete for millions of keywords, etc.) and we are ranked 95% faster than all websites by Alexa. Faxo Search. However, we do utilize a home grown proprietary web server. Apache/mod_deflate just didn't cut it. When those files are compressed into the filesystem not only do you take a hit for your file with the minimum filesystem block size but all the unnecessary overhead in managing the file in the filesystem that the webserver could care less about. Your concerns should be total disk footprint and access/decompression time and secondarily speed in being able to get this data precompressed. The footprint is important because even though disk space is cheap you want as much as possible to fit in the cache.

在已经安装了Apache2和deflate模块的Ubuntu上(这是默认的),你可以在两个简单的步骤中启用deflate gzip压缩:

a2enmod deflate
/etc/init.d/apache2 force-reload

你走了!我发现我通过adsl连接访问的页面加载得更快。

编辑:根据@GertvandenBerg的评论,这支持gzip压缩,而不是deflate。

GZip只是deflate加上一个校验和和页眉/页脚。不过,我从惨痛的教训中学到,通缩的速度更快。

(来源:typepad.com)