Question

I am trying to follow YSLOW's guidelines to optimize my site. I noticed that when static content like images, js and css files are hosted on my main domain, they are downloaded with unnecessary cookies. Therefore, I put them on a new domain (not subdomain) to avoid this.

I then found out that YSLOW says that this static content needs far future expire headers. Wouldn't that cause cookies to be enabled? Is this an either/or case or is it possible to host static content on a cookie free domain AND add expire headers? If so, how?

Was it helpful?

Solution

Cookies are not expire headers. Cookies are set with the Set-Cookie HTTP header, which specifically instructs the browser to save a small piece of text and send it again every time it contacts the same domain. Expire headers are set with the Expires and related headers and tell the browser when the content should be regarded as expired. This causes the browser to not contact the server at all and cache the data locally.

They're both entirely separate headers and mechanisms. See here for a list of all the other headers you can send and their effect, and use your browsers inspector's network tab to have a look at what kind of headers are being sent back and forth on each request.

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