문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top