在 Web 上同时加载文件是否比顺序加载更快?

发布于 2024-10-05 15:06:10 字数 265 浏览 0 评论 0原文

我想按特定顺序将图像加载到我的网站中,但发现这会减慢我网站的总下载时间。

在 Web 上同时加载文件比顺序加载文件更快吗? 为什么?

我发现这很有帮助,但没有完全回答我的问题: http://code.google.com/speed/page-speed/docs /rules_intro.html

I wanted to load images into my site in a certain order, but found that to slow down the total download time of my site.

Is it faster to load files simultaneously, on the Web, rather than sequentially?
Why?

I found this to be helpful, but didn't answer my question completely:
http://code.google.com/speed/page-speed/docs/rules_intro.html

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

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

发布评论

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

评论(3

高冷爸爸 2024-10-12 15:06:24

我发现连续下载 4 次左右是最佳选择。再多的话,你也看不到速度有多大的提高。为此,您需要定义 4 个不同的子域来获取文件。浏览器通常不会从同一服务器下载多个文件。

I've found the sweet spot to be around 4 sequential downloads. Any more and you don't see much improvement in speed. To get this you will need to define 4 different sub-domains to grab the files. Browsers don't usually download multiple files from the same server.

画骨成沙 2024-10-12 15:06:21

顺序下载的部分速度问题是每次下载都必须完成连接设置。

如果您的 Web 服务器正确处理管道请求,那么这就不是什么大问题。

另一个问题是,对于单个下载流,TCP 在稳定下载速度之前会开始不稳定(慢、太快、不太快、太快、快)。使用多个连接可以消除这种情况,从而消除每个 TCP 会话的波峰和波谷。

Part of the speed problem of sequential downloads is the connection setup must be done for each download.

If your web server is correctly handling pipeline requests then this isn't so much of an issue.

Another problem is that with a single download stream TCP starts out choppy (slow, too fast, not very fast, too fast, fast) before it settles into a steady download speed. Using multiple connections smooths that out so the peaks and valleys of each TCP session cancel out.

草莓味的萝莉 2024-10-12 15:06:19

有更好的方法来优化图像加载。您可以使用 CSS Sprites 在多个位置实际重复使用相同的图像文件,但使用定位和剪辑每次只显示一部分。

您还可以使用延迟加载,以便仅加载屏幕上显示的图像。

CSS Sprites

http://www.alistapart.com/articles/sprites

http://css-tricks.com/css-sprites/

延迟加载

http://www.appelsiini.net/projects/lazyload

There are better ways to optimize image loading. You can use CSS Sprites to actually reuse the same image file in multiple places but use positioning and clipping to only show part each time.

You can also use delayed loading so you only load images that are shown on the screen.

CSS Sprites

http://www.alistapart.com/articles/sprites

http://css-tricks.com/css-sprites/

Delayed Loading

http://www.appelsiini.net/projects/lazyload

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