Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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.

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.

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

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top