在单独的子域上托管图像 [英] Hosting images on separate sub domains

查看:124
本文介绍了在单独的子域上托管图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的公司拥有大约30个网站,它们共享相同的代码库并重复使用许多相同的图像。现在,所有网站的图片都托管在一个域中,然后每个其他网站都必须链接到这些图片。

My company hosts about 30 web sites all sharing the same code base and reusing many of the same images. Right now, the images for all of the sites are hosted on the one domain, and then every other site has to link to those images.


www.example.com/images/hello.jpg

i.e., www.example.com/images/hello.jpg

和www.example2.com上的内容类似:
< img src =http://www.example.com/images/hello.jpg/>

and on www.example2.com we have something like: <img src="http://www.example.com/images/hello.jpg" />

最近有人告诉我我应该将所有这些共享/静态图像放在子域上,但我没有看到它的优点。我听说可能会有轻微的速度增加,但我也听说它会使事情复杂化。有人可以详细说明吗?

Recently someone told me that I should be putting all of these shared/static images on a subdomain, but I don't see the advantages to this. I have heard that there might be a slight speed increase, but I've also heard that it can complicate things. Can someone elaborate?

推荐答案

它有几个好处:


  • 单独的域名可以防止您的域名Cookie被发送到每个不需要的图片请求。减少每个请求的带宽开销。

  • 大多数浏览器一次只能向特定域发出一定数量的HTTP请求,因此可能会在第二个域中提供图像和其他静态内容一次可以将HTTP请求的数量加倍。

  • 您可以设想使用不同的,重量更轻的网络服务器(如nginx / lighttpd)来提供静态内容。

下行:


  • 管理它。

  • 两个DNS查找而不是一个。

这篇关于在单独的子域上托管图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆