views:

216

answers:

2

Hi there!

I'm using Amazon S3 for my static files (pics, js and css). The S3 url is a subdomain of my main webapp (http://s.webapp.com)

Google's PageSpeed and Yahoo's YSlow warn to 'Use cookie-free domains' and 's.webapp.com' is one such domains using cookies but not really needing to.

How do I disable cookies in my Amazon S3 subdomain?

thanks, cheers

+3  A: 

By default cookies will be set for all hosts in a domain. If you are using cookies and you want to make sure they aren't sent for your "s." host, just make sure that when you set a cookie that you use "www.webapp.com" as the host rather than the default of ".webapp.com" (which would include all hosts).

Another alternative, especially if you have other hosts that will need to share cookies, is to just register another domain, say "webappstatic.com" and use that for your S3 content. I believe that is the solution that most big sites using S3 use.

Eric Petroelje
You're right about the subdomains. But my web-app doesn't use the www. subdomain: it always defaults to the webapp.com. So, really can't set cookies to only the www. subdomain. I tought that 'not allowing cookies' was a server/domain configuration.
sopppas
@sopppas - nope, it's not a server or domain configuration issue. It's simply a matter of just not sending any cookies.
Eric Petroelje
+2  A: 

As your S3 subdomain is a subdomain of you webapp domain you won't be able to stop cookies being sent. They're always sent to subdomains of the domian that sets them.

Stack Overflow had the same problem, which is why static resources are served from sstatic.net and not static.stackoverflow.com.

Dave Webb