2013-08-25 11:53
浏览 70


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?

图片转代码服务由CSDN问答提供 功能建议

我正在尝试遵循YSLOW的指南来优化我的网站。 我注意到,当我的主域上托管像图像,js和css文件这样的静态内容时,会使用不必要的cookie下载它们。 因此,我将它们放在一个新域(不是子域)上以避免这种情况。

然后我发现YSLOW说这个静态内容需要远期未来的过期标头。 这不会导致cookie被启用吗? 这是一个或两个案例,还是可以在无cookie域上托管静态内容并添加过期标题? 如果是这样,怎么样?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

  • doutang1873 2013-08-25 13:25

    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.

    解决 无用
    打赏 举报

相关推荐 更多相似问题