How do I setup IIS with a cookieless domain to improve performance?
Asked Answered
B

5

22

I was reading in google's documentation their new pagespeed plugin, that they recommend using cookieless domains to improve performance:

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.

Does anybody know how to do this in IIS?

Buttaro answered 5/6, 2009 at 15:22 Comment(3)
serverfault.com might get you more resultsOrji
There are plenty of IIS related questions on SO, so I think it's appropriate (including one from you: #322439)Buttaro
This is defo a SO dev related question.Hochman
H
24

What the Google article is suggesting is that you serve all your static content from another domain where cookies are not initially set by that serving domain.

Cookies are set in two ways - by session cookies (e.g. by ASP or ASP.NET requests) or explicitly by your application.

These will be posted back TO the server on each subsequent request for the domain that set the cookie (regardless of whether the request is for static or dynamic content) thus increasing the request payload.

What you're doing by having a second domain to serve static content (HTML, CSS, Images etc) is making cookie free requests because no initial cookie would be set in the first place for that domain.

In IIS it's your application, ISAPI Filter or ISAPI extension that will add a cookie. If your IIS server is not intercepting requests for static content (because this is usually handled by the kernel mode http.sys driver) then no cookies will be added to the response. It's only further up the request pipeline that cookies come into play.

So basically there isn't a way to explicitly configure cookie-less domains in IIS.

Hochman answered 5/6, 2009 at 15:39 Comment(0)
S
9

If you simply put all your static resources into, for instance, static.mysite.com, and if you never set any cookies in that domain, then the browser will never send a cookie when retrieving a resource from your static domain.

That's all Google is saying. There's nothing to configure, just to organize.

Saltzman answered 5/6, 2009 at 17:43 Comment(1)
Yeah, but does eliminating this more than make up for the increased dns lookup? If your page contains dns content from more than one domain (even if it is one of your own sub-domains), doesn't this require 2 dns lookups?Rida
S
6

AFAIK google analytics sets cookie for all subdomains, so it would be useless if you are using analytics?

I've experienced this also, you'd have to use a different domain altogether to avoid analytics/adsense cookies being set. Using static.yourdomain.com won't cut it.

Here's to hoping Google will change their analytics cookies so that we won't all have to buy new domains to serve cookie-less content.

Shithead answered 10/6, 2009 at 13:7 Comment(0)
L
3

AFAIK google analytics sets cookie for all subdomains, so it would be useless if you are using analytics?

Lives answered 7/6, 2009 at 5:16 Comment(2)
How should Google Analytics know about the subdomain?Cassimere
@olaf, it doesn't, it just assumes everything under it, e.g. *.mydomain.comAbott
L
1

Here's an example using the Google Analytics asynchronous tracking code, of how to set the domain for tracking: _gaq.push(['_setAccount', 'UA-XXXXXXX-x'],['_setDomainName', 'www.example.com'],['_trackPageview']);

Here's an example using the previous version of tracking code:

var pageTracker = _gat._getTracker("UA-XXXXXXX-x");
pageTracker._setDomainName("www.example.com");
pageTracker._trackPageview();

and here's what Google has to say about this: Google Analytics & Cookies

Lawley answered 10/6, 2010 at 22:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.