我刚刚创建了Javascript &使用YUI Compressor优化文件大小的CSS处理程序& GZip或Deflate压缩程序取决于请求标头。以下代码用于通过GZipStream类压缩文件。但我发现它只能从减少JQuery 1.3.2(YUI压缩)文件大小58KB - > 54KB。用GZip,Deflate压缩javascript文件的最佳组件是什么?
public void GZipCompressFile(string filePath, string compressedFilePath)
{
FileStream sourceFile = File.OpenRead(filePath);
FileStream destFile = File.Create(compressedFilePath);
using (GZipStream compStream = new GZipStream(destFile, CompressionMode.Compress))
{
int theByte = sourceFile.ReadByte();
while (theByte != -1)
{
theByte = sourceFile.ReadByte();
}
}
sourceFile.Dispose();
destFile.Dispose();
}
另一方面,我使用gz格式(超压缩模式)压缩文件与7-Zip。压缩文件的大小只有19.3 KB。但是,我不能使用7-Zip作为默认压缩器。因为它不能使用Deflate压缩器方法压缩文件。
你有没有压缩文件的任何组件GZip & Deflate文件类型?或者你有任何想法编辑我的GZipCompressFile方法?此外,所有新的浏览器(IE8,FF3.5,Opera 9.6,Safari 4)是否都支持压缩方法(包括GZip和Deflate)?
我认为它发生偏转,其DEFLATE – rahul 2009-07-01 07:02:11
对不起。这是我的错误。 – 2009-07-01 07:16:08