Current time: 12-12-2019, 11:41 PM Hello There, Guest! (LoginRegister)

Post Reply 
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to get rid of cookies (I'm on a CDN)
03-04-2011, 02:31 AM (This post was last modified: 03-04-2011 02:37 AM by Marvin.)
Post: #1
How to get rid of cookies (I'm on a CDN)
[Image: 1_optimization.png]

The pull location for my CDN is the root of my site, http://www.example.com. So cdn.example.com in reality mirrors the entire http://www.example.com, but my site, http://www.example.com, only links the static content from the cdn.example.com. That's I believe how it is also set up here at http://www.webpagetest.org.

Questions:

1. What can I do to have no cookies on the images, .js, and .css?

2. Will there be any impact on the load time? At least 10, 20, or 30ms?

Marvin
Find all posts by this user
Quote this message in a reply
03-04-2011, 02:49 AM
Post: #2
RE: How to get rid of cookies (I'm on a CDN)
1 - You can either change how you set the cookies and set them to http://www.example.com instead of to example.com (and you may not have control over all of them) or instead of using cdn.example.com you can use http://www.cdnexample.com and put the static content on a completely different domain.

2 - Possibly but it's going to be REALLY small and depend on how large your cookies are. If you only have a few cookies and they are relatively short it's probably not worth the effort (webpagetest.org cookies get applied to my static content as well because it's not really worth the effort for how few there are).
Visit this user's website Find all posts by this user
Quote this message in a reply
03-04-2011, 03:40 AM
Post: #3
RE: How to get rid of cookies (I'm on a CDN)
[Image: 1_optimization.png]

Pat, you are a gentleman, and I thank you very much! I set the cookie domain to http://www.example.com as you suggested was one option I had. It worked, as you can see on the screenshot above.

Marvin
Find all posts by this user
Quote this message in a reply
03-05-2011, 12:43 AM
Post: #4
RE: How to get rid of cookies (I'm on a CDN)
If you do that just make sure you have a redirect for non-www to www for your site, otherwise the cookies won't get sent if they try and access a page through non-www.
Find all posts by this user
Quote this message in a reply
03-05-2011, 01:00 AM
Post: #5
RE: How to get rid of cookies (I'm on a CDN)
Very good point, Jarrod, thanks. I do have the redirect in my .htaccess file.

Marvin
Find all posts by this user
Quote this message in a reply
03-25-2011, 11:04 AM (This post was last modified: 03-25-2011 11:06 AM by ckelly06.)
Post: #6
RE: How to get rid of cookies (I'm on a CDN)
Hi guys,

I'm confused by this. There's only one page on my site that sets cookies, and after reading this post I changed the domain from .datesphere.com to .www.datesphere.com. However, I'm still failing all the cookie tests when you look at my results.

I looked around and found the below excerpt from Yahoo's Best Practices for Speeding Up Your Site page:

Quote:If your domain is http://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 http://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.

So am I just screwed forever since I already set cookies on the naked domain? This "you can't fix it" explanation seems flat out bizarre, as I'm used to being able to fix / undo things on the internet, especially since it sounds like Marvin was able to change the cookie domain and it worked.

Any ideas on what I did wrong / why this didn't work for me?

Thanks,

Chris
Find all posts by this user
Quote this message in a reply
03-25-2011, 11:14 AM
Post: #7
RE: How to get rid of cookies (I'm on a CDN)
Well, you did half of the solution by setting the cookie to the fqdn, but all of the static resources are still being served from http://www.datesphere.com. You need to serve them from a different fqdn otherwise they will still carry the cookies (static.datesphere.com for example).

That said, cookies is probably one of the last things you should focus on. Once you reduce the number of requests you'll be serving less than 10 requests total and it looks like there's only the one cookie so it's really not going to make a measurable difference.

-Pat
Visit this user's website Find all posts by this user
Quote this message in a reply
03-25-2011, 11:44 AM
Post: #8
RE: How to get rid of cookies (I'm on a CDN)
Oh... I get it. And when you say "you'll be serving less than 10 requests" I guess you mean once all my images are served from a sprite (since those are the vast majority of my requests now)?

I'll have to look into how to do this since the images are being served dynamically - have never used sprites before.

Thanks, Pat.
Find all posts by this user
Quote this message in a reply
03-26-2011, 02:37 AM
Post: #9
RE: How to get rid of cookies (I'm on a CDN)
Yep - dynamically may be more difficult though (is it dynamically selected from a reasonable set of possible images or a huge pool of images)? Are they all dynamic or are some of them static (like the flags)?
Visit this user's website Find all posts by this user
Quote this message in a reply
03-26-2011, 02:56 AM
Post: #10
RE: How to get rid of cookies (I'm on a CDN)
All the images are generated based on php variables, so I guess I'd say they're all dynamic. I understand sprites in theory (having one big image containing all your images and showing only a specific part using css rules for each individual image), but I'll have to read up on how you make it work when images are being pulled in dynamically. I'm sure there's a way to do it.
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)