Serving static files via a cookiless subdomain?

Hi All,
We serve MANY .mp3 file and images. These files hardly ever change so
thinking about serving them off of a “cookieless” domain per suggestion
the yslow component.

  1. Does it make sense in general to do this?

  2. How would you do it in Nginx?

Currently we just have one webserver, we are thinking about adding

This depends somewhat on how your site stores cookies. If your
website lives at, it can store cookies at either” or just “”. The reason this matters is
that all “” cookies will be sent in requests for
*, but “” cookies will only be sent to
requests at (e.g., not to As
such, you can use a subdomain (rather than a separate domain) if your
cookies are stored with a “www” prefix.

You can find out some pretty detailed information on this here:

There’s a lot of other good information at that site that points out
how to optimize websites for speed.

I doubt if the .mp3 downloads will benefit much from not sending
cookies in the header, mostly because they aren’t (usually) downloaded
in quick succession the way images are. Also note that most browsers
limit to four connections per host while downloading assets, so if you
have a lot, consider spreading them out over multiple subdomains, such
as,, etc.

As far as doing this in nginx, there are many ways. The simplest
would be to just add more hosts to your server_name declaration. If
you want to limit the asset hosts to just serving assets, then just
add a new server block:

server {

server_name … ;
root … ;
location / {


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs