以提高网站性能停止饼干正在从一个域(;无Cookie域&QUOT又名&QUOT)设置 [英] Stopping cookies being set from a domain (aka "cookieless domain") to increase site performance

查看:175
本文介绍了以提高网站性能停止饼干正在从一个域(;无Cookie域&QUOT又名&QUOT)设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在阅​​读中谷歌的有关提高网站的速度文档。他们的建议之一是从无Cookie域提供静态内容(图片,CSS,JS等):

I was reading in Google's documentation about improving site speed. One of their recommendations is serving static content (images, css, js, etc.) from a "cookieless domain":

静态内容,例如图像,JS和
  CSS文件,也不需要是
  伴随饼干,因为有
  这些没有用户交互
  资源。您可以降低要求
  通过提供静态资源的延迟
  从没有担任域
  饼干。

Static content, such as images, JS and CSS files, don't need to be accompanied by cookies, as there is no user interaction with these resources. You can decrease request latency by serving static resources from a domain that doesn't serve cookies.

谷歌则表示,要做到这一点的最好办法是买一个新的领域,并将其设置为指向当前的一项:

Google then says that the best way to do this is to buy a new domain and set it to point to your current one:

要保留一个Cookie的域
  提供静态内容,注册一个新的
  域名和配置你的DNS
  数据库与CNAME记录
  指向新域名到现有的
  域的记录。配置你的Web
  服务器,用于为静态资源
  新域,并且不允许任何
  饼干在任何地方设置该
  域。在您的网页,参考
  该域名的网址
  静态资源。

To reserve a cookieless domain for serving static content, register a new domain name and configure your DNS database with a CNAME record that points the new domain to your existing domain A record. Configure your web server to serve static resources from the new domain, and do not allow any cookies to be set anywhere on this domain. In your web pages, reference the domain name in the URLs for the static resources.

这是pretty直线前进的东西,除了在那里它说:该位的配置Web服务器从新域服务静态资源,并且不允许任何cookie随时随地在这个设置域。 <一href=\"http://stackoverflow.com/questions/956458/how-do-i-setup-iis-with-a-cookieless-domain-to-improve-performance/956586#956586\">From我读过,有在IIS中没有设置,允许你说提供静态资源,所以我怎么从这个新的域名设置cookie prevent ASP.NET?

This is pretty straight forward stuff, except for the bit where it says to "configure your web server to serve static resources from the new domain, and do not allow any cookies to be set anywhere on this domain". From what I've read, there's no setting in IIS that allows you to say "serve static resources", so how do I prevent ASP.NET from setting cookies on this new domain?

在present,就算我只是请求来自新域.jpg格式,它设置在我的浏览器的cookie,尽管我们的应用程序的cookie被设定为我们的老域名。例如,ASP.NET设置一个.ASPXANONYMOUS的cookie的(据我所知)我们还没有告诉它做的事。

At present, even if I'm just requesting a .jpg from the new domain, it sets a cookie on my browser, even though our application's cookies are set to our old domain. For example, ASP.NET sets an ".ASPXANONYMOUS" cookie that (as far as I'm aware) we're not telling it to do.

道歉,如果这是一个真正的问题福利局,我是新这个!

Apologies if this is a real newb question, I'm new at this!

感谢。

推荐答案

如果你不写,从域的Cookie,该域名将是无cookie。

在该域将举办类似的脚本,图片等资源只有内容,它们是由浏览器的纯HTTP-GET请求,请求。这些内容应担任原样。这将使您的域名Cookie的。这不能由网络服务器的配置来完成。 HTTP是完全无状态和网络服务器有没有关于饼干主意。 Cookies是书面或通过服务器端脚本发送到客户端。 你能做的最好的就是在IIS应用程序禁用asp.net,经典ASP或PHP脚本的能力。

When the domain is set to host only resource content like scripts, images, etc., they are requested by plain HTTP-GET requests from browsers. These contents should be served as-is. This will make your domain cookieless. This cannot be done by web-server configuration. Http is completely state-less and web-servers have no idea about the cookies at all. Cookies are written or sent to clients via server-side scripts. The best you can do is disable asp.net, classic-asp or php script capabilities on the IIS application.

在路上,我们做的是。

我们有一个子域设置服务cookie的资源。因此,我们主机上的子域我们所有的图像和脚本。并从主应用程序,我们只需点按它的资源的URL。 我们确保子域保持cookie的免费通过该域名不投放任何动态脚本或创建任何asp.net或php会话。

We have a sub-domain setup to serve cookie-less resources. So we host all our images and scripts on the sub-domain. and from the primary application we just point the resource by it's url. We make sure sub-domain remains cookie-free by not serving any dynamic script on that domain or by creating any asp.net or php sessions.

http://cf.mydomain.com/resources/images/*.images
http://cf.mydomain.com/resources/scripts/*.scripts
http://cf.mydomain.com/resources/styles/*.styles

从主域,我们只是参考的资源如下。

from primary domain we just refer a resource as following.

<img src="http://cf.mydomain.com/resources/images/logo.png" />

这篇关于以提高网站性能停止饼干正在从一个域(;无Cookie域&QUOT又名&QUOT)设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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