0

Using Yslow, it's complaining about cookie free components. I understand what the problem is, but is there no solution other than using a subdomain? Using a subdomain can create SSL issues, especially along with CDN, and plugin updates.

Is there not an alternative? Such as a script that says "don't cookie these components?"

Thanks.

4

1 回答 1

1

When a cookie is set for a domain, the browser sends it for every request, as long as the cookie is not expired. So no, there is no way to say "don't send cookies for this request" except a different domain which you mentioned.

Depending on your website, you can, instead of using cookies, use:

  • query parameters: GET my_file.php?my_session_id=abcd123456
  • custom headers (for ajax requests only): you can set HTTP headers X-MY-SESSION-ID: abcd123456
  • POST body variables

You asked for alternatives, so I gave some but it's hard to implement these if all you want is to avoid sending cookies when loading a static asset.

So my suggestion is to look at how many extra bytes you're actually sending for each request and trying to reduce that to a minimum.

In my opinion, only one cookie is really needed for the user's session id, so that's about 50-60 bytes. You may also choose to use Google Analytics, which will add about a couple hundred bytes. Everything besides that is bloat. But don't sweat it if Yslow shames you for 300 extra bytes, because it won't make a huge difference.

于 2012-11-11T14:13:53.493 回答