Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to create a "" domain to serve static content to my original domain. How would I make the "" domain to so its cookie-free when loading content? I am thinking that this should be done using a htaccess file but not too sure and the information online is hard to follow. I would also like to enable gzip on the static domain to reduce the download size of static content. How would I set this up?

I would like to set this up on my Apache server to load images. Any specific ideas or instructions would be appreciated!

Thank you Pawel

share|improve this question
you need to force (naked) to else will get all of's cookies – Neil McGuigan Dec 17 '12 at 2:55
up vote 10 down vote accepted

Don't bother setting up gzip compression for images unless you are serving uncompressed image types.

All the common image types (png, gif, jpeg) are already compressed and you will not gain much at all (if anything) from recompressing with gzip. It will just take up more resources for users when their browser receives them.

Gzip on the web should only be used for text content like javascript, css and html.

As for cookies, I agree with Devin. Just don't set cookies on that domain and it will be a cookie free domain.

Edit to expand on my answer:

If the static content you speak of is html, js, and css, it would be better to create a handler in a server-side language to see if people have gzip enabled in their browser. Almost everyone should have it enabled, but some don't and you'd be cutting them out. You would have to keep a standard version of each file and then another version of it gzipped ".gz".

You could just enable mod_deflate on apache to compress certain types of files, but it would do on-the-fly compression every time the file is requested. That is a waste of CPU in my opinion, which is why I suggest you keep two copies of the static files like I suggested and use a server side language to determine which to send.

share|improve this answer
+1 - never setting any cookies on that domain will ensure that no cookies are ever sent. In other words, make sure that ONLY images/css/js are linked from that domain, and that if you ever type that domain name in your browser you just get a blank page, or a page explaining what the domain is used for and link back to the original site. See for an example. – Mark Henderson Aug 22 '09 at 22:08
ok i understand. Yes, so my ideal solution would be to have a domain like "". Would there be a difference between creating a subdomain vs. getting a completely different domain to use for static content? So for example, "" vs. ""? Would there be a performance difference as well? Thank you – pppglowacki Aug 22 '09 at 23:27
@pawel: the only time there would be a difference is if you had previously set a cooking for (rather than, or as well as, in that case, the cookie will be used for all subdomains, including – cas Aug 23 '09 at 3:14
BTW, always use "" rather than some arbitrary domain name for DNS examples. is guaranteed to not be in use by anyone, but could be registered (and, in fact, is - by a domain squatter) – cas Aug 23 '09 at 3:17

If you have, and, you will not be able to set a wildcard cookie * in your www site that will persist in the store site (for example to transfer a shopping cart) without it also being sent to images site by browsers.

This one reason site choose to use additional domains like - another reason for doing so is if you decide to use a third-party CDN rather than buying additional servers yourself, in which case it can simplify configuration. The downside is that if you serve flash content from a different domain, you may need to watch out for cross-domain restrictions.

share|improve this answer
If you happens if you set a htacces file insite * that redirects to Will this still send the cookie? – Saif Bechan Mar 10 '10 at 20:19

Not sure I understand. If you don't send any cookies tied to this domain, then there won't be any cookies. Cookies are only sent for your domains if your software tells them to be sent, they aren't something users put there arbitrarily.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.