压缩页面以使其加载速度更快

发布于 2024-07-23 11:52:17 字数 90 浏览 2 评论 0原文

有没有办法压缩 html 页面或 asp.net 页面的 html 输出,使它们加载得更快。 我听说谷歌正在以某种方式使用该技术。

提前致谢。

Is there any way to compress an html page or html output of asp.net page to make them load faster. I heard that Google is using that technology someway.

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

蓝颜夕 2024-07-30 11:52:17

当然可以打开 http 压缩来减少通过网络传输的数据的大小,并且所有现代浏览器都知道如何解压缩响应。 由于传输的数据较少,它只会缩短加载时间。 如果这不是瓶颈所在,您可能看不到您希望的改进。 如果您正在寻找提高网页性能的其他方法,您可能还需要查看 YSlow 或 Page Speed 等工具。

It's certainly possible to turn on http compression to reduce the size of the data transmitted over the network and all modern browsers will know how to unzip the response. It only improves the load time due to less data being transferred though. If that's not where the bottleneck is, you may not see the improvement you're hoping for. You may also want to look at tools like YSlow or Page Speed if you're looking for other ways of improving the performance of a web page.

拥抱我好吗 2024-07-30 11:52:17

是的,以 Content-Encoding: gzip 形式交付页面可能会更快地将页面本身交付给浏览器。 但是,如果真正的问题是用户认为页面加载缓慢,则您需要记住显示页面的过程有几个部分,而您只查看其中的一个部分。 加载页面本身的 HTML 后,浏览器仍然必须解析它,开始执行页面中的任何脚本,并加载页面所需的任何其他数据(例如图像)。 最后一部分花费大量时间通常会导致页面显示缓慢。

Yes, delivering the page as Content-Encoding: gzip will probably deliver the page itself to the browser more quickly. But if the real problem is that the page appears to the user to load slowly, you need to remember that the process of displaying the page has several parts, of which you're looking at only one. After loading the HTML for the page itself, the browser still has to parse it, start executing any scripts in the page, and load any further data (such as images) that the page requires. This last part taking a lot of time is often what makes a page appear to display slowly.

多情癖 2024-07-30 11:52:17

另一种非 IIS 特定的方法是测量页面的哪些部分加载时间最长。
Yahoo! 的 yslow 是一个不错的免费工具
您还可以尝试使用 pngcrush 等工具或在线实用程序 smush-it
如果您使用了大量 CSS,您可以使用 CSSTidy 将其最小化。

Another, non IIS specific approach is to measure what parts of your page are taking the most time to load.
A good and free tool is yslow from Yahoo!
You can also try to optimize your image files with tools like pngcrush or the online utility smush-it
If you are using a lot of CSS you can minimize it with CSSTidy.

伪装你 2024-07-30 11:52:17

我知道您使用的是 asp.net,但是对于遇到此问题并使用 apache 的任何人来说,最好的(最快、占用 CPU 资源最少)的压缩方法是 mod_deflate, 。

这就是我在 .htaccess 中使用的:

# Insert filter
SetOutputFilter DEFLATE

# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html

# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip

# MSIE masquerades as Netscape, but it is fine
# BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary

来源:http://httpd。 apache.org/docs/2.0/mod/mod_deflate.html

并有证据表明它更快:http://www.google.co.uk/search?q=deflate+vs+gzip

I know your using asp.net, but for anyone who comes across this and is using apache, the best (fastest, least cpu intensive) method of compression is mod_deflate, .

This is what I use in my .htaccess:

# Insert filter
SetOutputFilter DEFLATE

# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html

# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip

# MSIE masquerades as Netscape, but it is fine
# BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary

Source: http://httpd.apache.org/docs/2.0/mod/mod_deflate.html

And for evidence that it is faster: http://www.google.co.uk/search?q=deflate+vs+gzip

眼眸里的那抹悲凉 2024-07-30 11:52:17

在 google 上搜索术语“gzip”

Do a google search for the term "gzip"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文