Media, Cookies & Domains

March 2nd, 2010  |  Published in PHP, Tips, Web Development

With all the brilliant tools (Google Page Speed, YSlow, etc.) out there, web professionals can now easily see a few basic things to improve page speed performance. One suggestion is to send static content from a cookieless domain. On most sites I’ve worked with, we serve static content from a media subdomain and then the real content from the main domain (without www). I know with cookies, if the domain is .indirecthit.com it would send that cookie to any subdomain on indirecthit.com, therefore the media subdomain would have a cookie. An easy change: remove the . from the cookie domain. But when I looked at the PHP manual for setcookie, I came across the following statement:

The . is not required but makes it compatible with more browsers.

That doesn’t sound very good, I want it to be compatible with all browsers…

I couldn’t find much on it, from what I did find I believe the reason it doesn’t work with all browsers is for security. If I had the domain er.com, and I set a cookie to the domain er.com (notice the missing .), the browser could match this with older.com or lesser.com. If the website at er.com set the cookie to er.com (without the first .), the web server on older.com or lesser.com can access this cookie…not good. Therefore, even if I remove the . from the domain, it still would match media.indirecthit.com and that domain wouldn’t be cookieless.Doesn’t solve my problem and isn’t compatible with most browsers.

The solution, is to split out your media server on a different domain such as indirecthitmedia.com. This is why when you visit some Google properties it loads media content from gstatic.com not media.google.com or google.com. And obviously you don’t set any cookies to this new media domain. You will now score a bit higher on Google Page Speed and YSlow. Congrats!

Previously


Nov 10, 2008
Table Centering Inheritance

by | Read | No Comments

I recently came across a little cross-browser issue with using the align attribute in tables. The problem was that we had some cells centering in Internet Explorer and Opera but not in Safari and Firefox. The result was how the inheritence of the align attribute is handled by the different browsers. The first image below [...]

Continue Reading →


Jun 12, 2008
Private RSS Feeds & Feed Readers

by | Read | 5 Comments

We’re planning an event here at Well.ca, a secret event. But that’s not what this post is about. To organize and send out invites for this event I suggested we use MyPunchBowl. I haven’t done much with it, but it looked half decent and I’ve heard good things about it. There was one problem with [...]

Continue Reading →


Jun 2, 2008
Django Caching Middleware & Login Page

by | Read | 2 Comments

Recently on StartupIndex.ca, I’ve noticed a problem where the first time you login it fails, the second time it works. I sat down last night, and spent some time attempting to solve this problem. My search on the greater web didn’t end up with very many results, I did find one mailing list thread on [...]

Continue Reading →


May 30, 2008
StartupIndex.ca Article in ComputerWorld Canada

by | Read | No Comments

Jevon and I were interviewed by ComputerWorld Canada yesterday. The article just went up this morning. Can get to it here: http://www.itworldcanada.com/a/Daily-News/25b53438-4513-4bda-8527-0350f9672ae7.html

Continue Reading →


May 29, 2008
JSR 311 – Java REST Libraries

by | Read | 3 Comments

I’m starting to work on a project at Well.ca using Java and REST. Knowing the amount of REST libraries out there for other languages, I figured there would be a good amount for Java. Wrong! There is a Java specification currently in draft for REST, it’s called JSR 311. Now the problem with this is [...]

Continue Reading →


May 29, 2008
StartupIndex.ca Updated with Widgety Goodness

by | Read | No Comments

I updated StartupIndex.ca yesterday with some new features. Ali updated the map on the frontpage to be more intelligent and fixed some annoying problems with it. Now it looks better and responds better. We now have widgets! See below for an example widget, but this code can be placed into any webpage to give information [...]

Continue Reading →

Subscribe via RSS

If you like the content of this website and are looking for a way to be notified of new content, look no further. Just click the orange icon to your right and subscribe using your favorite feed reader.




http://mp3tomidiconverter.com/ allows you to convert audio