Cookie-free Domains

所谓 Cookie-free Domains, 翻译成中文叫"饼干免费域名"
但是翻译英文的时候有一种高深的语法叫倒装, 一般同学难以理解就不用转牛角尖了
说白了就是反过来翻译, 那么正确的翻译就是 免费饼干域名!

聪明的同学一看就明白了
有点呆的同学继续听我讲

免费饼干域名 说白了就是这个域名不会产生cookie

为什么不能让域名产生 cookie 呢?

当浏览器向服务器请求一张静态的图片前,会先发送同域名下的 cookie,服务器对于这些 cookie 不会做任何处理。因此它们只是在毫无意义的消耗带宽。所以你应该确保对于静态内容的请求是无coockie的请求。

域名加WWW的好处是什么?

如果我给 http://ooxx.me 设置了cookie,那么会感染所有子域名, 请求 http://plz.ooxx.me/logo.gif 时便会带上讨厌的cookie
但如果我给 http://www.ooxx.me 设置了cookie, 并不会感染其他子域名或主域名

域名不加WWW的好处

也许女孩子们不喜欢,但没错, 不加 WWW 的唯一好处就是 短

毫无疑问, 咱的域名都是被污染过的, 无法通过开一个二级域名存放图片CSS JS等静态资源
但咱有钱,可以买个域名专门放图片
Yahoo!使用的是 ymig.com,YouTube使用的是ytimg.com,
Amazon使用的是images-anazon.com, Miao.in使用的是 mediatempl.com(卖掉了)

插播广告: 世界上最大域名贩子 Godaddy.com , 只需要花$0.89 就可以买一个 .info 域名, 做 Cookie-free Domians 不是很二的选择
PS:续费很贵,用完就丢掉...




Use Cookie-free Domains for Components

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.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值