Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to use cookie-free domains (yslow)

I was trying to solve the problem with cookie-free, the yslow has suggested to create a subdomain. I did, but the yslow still "show" the problem.

i didn't set the cookie´s domain in the page, cause i don't know how to do it.

anyone know a tutorial or a solution to this problem?

like image 486
Mario Avatar asked Oct 03 '14 20:10

Mario


3 Answers

Create a subdomain such as static.yourwebsite.com which is where you will deliver all your static files from.

Point your new subdomain to the /wp-content directory for a WordPress installation.

For cPanel users, you will need to update the document root field from public_html/static to public_html/wp-content like the screenshot below. cpanel document root

Edit your config.php file to reflect the following:

define("WP_CONTENT_URL", "http://static.yourwebsite.com");

define("COOKIE_DOMAIN", "www.yourwebsite.com");

Now that your cookie domain and static content subdomain are set, you can begin delivering static content without the server setting an unnecessary cookie for static assets.

https://www.keycdn.com/support/how-to-use-cookie-free-domains/

like image 139
Leandro Costa Avatar answered Nov 19 '22 05:11

Leandro Costa


To work around this problem, make sure that static components are requested with cookie-free requests by creating a subdomain and hosting them there.

If your domain is www.example.org, you can host your static components on static.example.org. However, if you've already set cookies on the top-level domain example.org as opposed to www.example.org, then all the requests to static.example.org will include those cookies.

In this case, you can buy a whole new domain, host your static components there, and keep this domain cookie-free.

Yahoo! uses yimg.com, YouTube uses ytimg.com, Amazon uses images-amazon.com and so on.

Read More

like image 37
kupendra Avatar answered Nov 19 '22 03:11

kupendra


Serve static content from a different domain to avoid unnecessary cookie traffic. When the browser requests a static image and sends cookies with the request, the server ignores the cookies. These cookies are unnecessary network traffic.

  1. Move all your static content on a different domain, where no cookies are set.
  2. Move your static content on a different sub domain and set all the cookies to the www subdomain.
like image 27
Rizwan Mughal Avatar answered Nov 19 '22 03:11

Rizwan Mughal