Cookie free domains in Joomla - YSlow optimization
YSlow performance figures
When checking your Joomla site against the YSlow performance indicator without changing anything on your default configuration, you will get a recommendation for using cookie-free domains. Some more background information on this topic can be found at an article from Stoimen (Sections 1 & 2). Even if there is a lot of discussion on the usefulness of this topic, it's always nice to be able to improve your score with a minimum on effort.
The explanation on cookie settings in Joomla as explained below have made my YSlow performance figures go up with 1 to 2% - depending on the fact if all the cookies for images, css and js are created on your domain or not. The more images, css and js are served from your own domain, the more impact these changes will have on your score.
Joomla & cookie settings
So we will set a cookie domain for the overall site. Please be careful when playing around with the Cookie Domain name, as this can make it impossible to log in to your site on the administrator panel (been there, done that myself and it took me a couple of hours to find out the exact cause - it turned out to be the cookie settings we will discuss in this article).
Inside your Joomla Administrator panel, you go to System > Global Configuration. On the first tab, you will find the "Cookie Settings" in the right bottom corner of your screen. Now the magic begins:
- on the Cookie Domain, put ".example.com" (mind the dot at the start of your text) - please change the "example.com" into the name of your own domain
- on the Cooke Path, put "/rootofyoursiteontheserver/cookie" - please change the "rootofyoursiteontheserver" into the correct path to the root directory of your www-site, e.g. httpdocs or http.www (this depends on your hosting company, the 2 examples or for 2 of the companies on which sites under my administration or hosted)
First aid in case of emergency
I warned you, you need to be very careful when entering the values in the text fields for your cookie settings. The good news is that , if you have done something wrong in your settings, normally it will not effect anything on your YSlow score or other scores AFAIK.
But ... things can go terribly wrong if you want to log in into the administrator part of your site if the settings are not correct. If you encounter this kind of situation: no panic. Even if you can't change the settings in your administrator interface of your site, there is a workaround using your FTP software and a simple editor.
- Login via FTP to your site and download the file "configuration.php" (can be found in the root directory of your website)
- Once this file is inside your editor, search for $cookie_domain and $cookie_path and remove all text between the quotes (but keep the quotes - look at the images just below for more details).