使用多个子域名会加速我的网站吗?

时间:2022-12-05 07:49:33

i am considering moving my images to a subdomain on my website, and i read somewhere that moving the script to a different one would make it even faster! is it really true? or should i just leave it at what it is if i am not considering a real CDN?

我正在考虑将我的图像移动到我的网站上的子域,并且我在某处读到将脚本移动到另一个脚本会使它更快!这是真的吗?或者,如果我不考虑真正的CDN,我应该把它留在原来的位置吗?

1 个解决方案

#1


Yes and no. The site itself won't be faster, but it may load faster in most browsers and thereby it may seem faster.

是的,不是。网站本身不会更快,但它可能在大多数浏览器中加载速度更快,因此看起来更快。

The reason is that most browsers limit themselves to a set maximum of concurrent connections to a domain. Say you have your site on www.mysite.com. Now when your browser tries to download your html, css, scripts and images it may need to download 20-30 files from the server. Since the browser limits itself to, say 4, concurrent connections to your domain the browser will have to download only 4 files at one time.

原因是大多数浏览器将自己限制为与域的并发连接的设置最大值。假设您的网站位于www.mysite.com。现在,当您的浏览器尝试下载您的html,css,脚本和图像时,可能需要从服务器下载20-30个文件。由于浏览器将自身限制为(例如4)与您的域的并发连接,因此浏览器必须一次只下载4个文件。

Now if you serve your css files on a separate subdomain css.mysite.com, your images on images.mysite.com and scripts on scripts.mysite.com your browser can open 4 concurrent connections to each of the domains. Hence it can download up to 16 files at the same time. If your banwidth allows it this may cause the page to load faster.

现在,如果您在单独的子域css.mysite.com上提供css文件,您在images.mysite.com上的图像和scripts.mysite.com上的脚本,您的浏览器可以打开到每个域的4个并发连接。因此,它可以同时下载多达16个文件。如果你的banwidth允许它,这可能会导致页面加载更快。

So your site may appear to be faster for the visitor, but the reason will be loading times, not any speedup of code or database access.

因此,您的网站对访问者来说似乎更快,但原因是加载时间,而不是代码或数据库访问的任何加速。

#1


Yes and no. The site itself won't be faster, but it may load faster in most browsers and thereby it may seem faster.

是的,不是。网站本身不会更快,但它可能在大多数浏览器中加载速度更快,因此看起来更快。

The reason is that most browsers limit themselves to a set maximum of concurrent connections to a domain. Say you have your site on www.mysite.com. Now when your browser tries to download your html, css, scripts and images it may need to download 20-30 files from the server. Since the browser limits itself to, say 4, concurrent connections to your domain the browser will have to download only 4 files at one time.

原因是大多数浏览器将自己限制为与域的并发连接的设置最大值。假设您的网站位于www.mysite.com。现在,当您的浏览器尝试下载您的html,css,脚本和图像时,可能需要从服务器下载20-30个文件。由于浏览器将自身限制为(例如4)与您的域的并发连接,因此浏览器必须一次只下载4个文件。

Now if you serve your css files on a separate subdomain css.mysite.com, your images on images.mysite.com and scripts on scripts.mysite.com your browser can open 4 concurrent connections to each of the domains. Hence it can download up to 16 files at the same time. If your banwidth allows it this may cause the page to load faster.

现在,如果您在单独的子域css.mysite.com上提供css文件,您在images.mysite.com上的图像和scripts.mysite.com上的脚本,您的浏览器可以打开到每个域的4个并发连接。因此,它可以同时下载多达16个文件。如果你的banwidth允许它,这可能会导致页面加载更快。

So your site may appear to be faster for the visitor, but the reason will be loading times, not any speedup of code or database access.

因此,您的网站对访问者来说似乎更快,但原因是加载时间,而不是代码或数据库访问的任何加速。