CDN 和域

发布于 2024-08-26 19:20:26 字数 162 浏览 4 评论 0原文

许多大型网站(Facebook 等)都为其内容设置 CDN。现在我注意到,这些 CDN 并不总是位于原始域上。

示例:Facebook 图片位于“photos-a.ak.fbcdn.net”上,

这是为什么?在“主”域(facebook.com)上没有大量子域是否会带来性能提升

A lot of big websites (facebook etc) are settings up CDN's for their content. Now I notice, that these CDN's are not always on the original domain.

Example: Facebook pictures are on "photos-a.ak.fbcdn.net"

Why is that? Is there a performance-gain in not having lots of subdomains on the "primary" domain (facebook.com)

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

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

发布评论

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

评论(3

初雪 2024-09-02 19:20:26

对于用户来说,性能有相当大的提升,因为使用不同的域,浏览器将不再需要发送 cookie。

有关 Cookieless 域的详细信息,请阅读本文:http:// code.google.com/speed/page-speed/docs/request.html#ServeFromCookielessDomain

There is quite a large performance gain for the user because with a different domain, the browser won't have to send the cookies anymore.

Read this article for more info about cookieless domains: http://code.google.com/speed/page-speed/docs/request.html#ServeFromCookielessDomain

回首观望 2024-09-02 19:20:26

Stackoverflow 本身在其静态内容网站上对此进行了很好的解释。

当浏览器发出请求时
静态图像并发送cookie
与请求一起,服务器
那些没有任何用处
曲奇饼。所以他们只创建网络
没有充分理由的交通。你应该
确保静态组件
使用无 cookie 的请求进行请求。
创建一个子域并托管您的所有
那里有静态组件。

如果您的域名是 www.example.org,您可以将静态组件托管在
static.example.org。但是,如果您已经
已经在顶层设置了cookie
域 example.org 而不是
www.example.org,然后是所有请求
static.example.org 将包括
那些饼干。在这种情况下,您可以
购买一个全新的域名,托管您的
那里有静态组件,并保留它
无域 cookie。雅虎!用途
yimg.com,YouTube 使用 ytimg.com,
亚马逊使用 images-amazon.com 等
上。

在无 cookie 的域上托管静态组件的另一个好处是某些代理可能会拒绝
缓存组件
通过 cookies 请求。在相关的
请注意,如果您想知道是否应该使用
example.org 或 www.example.org 用于
你的主页,考虑cookie
影响。省略 www 就没有
选择但将cookie写入
*.example.org,因此出于性能原因,最好使用 www
子域并将cookie写入
该子域。

最初来自 雅虎。

Stackoverflow itself expains it very well on its static content site.

When the browser makes a request for a
static image and sends cookies
together with the request, the server
doesn't have any use for those
cookies. So they only create network
traffic for no good reason. You should
make sure static components are
requested with cookie-free requests.
Create a subdomain and host all your
static components there.

If your domain is www.example.org, you can host your static components on
static.example.org. However, if you've
already set cookies on the top-level
domain example.org as opposed to
www.example.org, then all the requests
to static.example.org will include
those cookies. In this case, you can
buy a whole new domain, host your
static components there, and keep this
domain cookie-free. Yahoo! uses
yimg.com, YouTube uses ytimg.com,
Amazon uses images-amazon.com and so
on.

Another benefit of hosting static components on a cookie-free domain is that some proxies might refuse to
cache the components that are
requested with cookies. On a related
note, if you wonder if you should use
example.org or www.example.org for
your home page, consider the cookie
impact. Omitting www leaves you no
choice but to write cookies to
*.example.org, so for performance reasons it's best to use the www
subdomain and write the cookies to
that subdomain.

Originally from Yahoo.

心安伴我暖 2024-09-02 19:20:26

CDN 通常分布在世界各地,因此与所有文件都位于主数据中心相比,用户更接近文件。

将单个域路由到不同的数据中心很困难(不可能?)。

此外,不再需要发送 cookie。对于 Facebook 来说,由于嵌入到整个网络中,它拥有大量的 cookie,这可以节省很大的开支。

A CDN is typically spread across the world so that the user is closer to files than if all files were in the main data center.

It is difficult (impossible?) to route a single domain to different data centers.

Also, cookies no longer need to be sent. For Facebook, which has a ton of cookies due to being embedded all over the web, this can be a big saver.

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