我有一个 ASP.NET Web 应用程序,我正在考虑以下问题:在向用户发送任何 HTML 或 CSS 内容之前,我希望“压缩”它们,然后缓存结果并将其发送给客户端。
我知道可以通过删除空格、注释和类似的东西来压缩它们,但我不太熟悉更高级的解决方案。
- 除此之外,还有哪些压缩方法以及每种方法的优点是什么?
- 某些浏览器或 HTTP 协议本身是否支持任何类型的压缩?
编辑:我也有兴趣对动态生成的 HTML 执行此操作。
I have an ASP.NET web application and I'm thinking about the following: before sending any HTML or CSS content to users, I wish to 'compress' them, then cache the result and send that to the clients.
I know it is possible to compress these by removing whitespaces, comments and stuff like that, but I'm not really familiar with more advanced solutions for this.
- Apart from this, what compression methods are there and what are the advantages of each of them?
- Does some browsers or the HTTP protocol itself support any kind of compression?
EDIT: I'm interested in doing this to dynamically-generated HTML, too.
发布评论
评论(2)
gzip
最常用于“高级”压缩(即,不仅仅是删除空格)。所有主要浏览器都支持它:http://www.gzip.org/。它使用 DEFLATE 算法。如果您只想缩小文件,请尝试:或者尝试 YUI Compressor 或任何其他流行的。
gzip
is most commonly used for "advanced" compression (i.e., not just removing whitespace). It is supported by all the major browsers: http://www.gzip.org/. It uses the DEFLATE algorithm. If you only want to minify your files, try:Or try YUI Compressor or any of the other popular ones.
您可以查看 google 提供的任何缩小方法,yahoo,microsoft 用于您的 javascript 和 css。他们都做得很好。看看这个文章 对这三者进行测试。
此外,您还可以拥有 IIS gzip 压缩您的所有内容,甚至缓存它(查看 http headers 选项卡以了解缓存)。
请查看这篇文章,了解加快网络应用速度的其他一些方法还。
You can look into any of the minify methods offered by google, yahoo, microsoft for your javascript and css. They all do a good job. Check out this article for tests on all three.
Additionally, you can have IIS gzip compress all your content and even cache it (look at the http headers tab for caching).
Have a look at this article for some other ways to speed up your web app also.