Want to know how to serve static content from a cookieless domain?
You came to the right place. In this article, I’ll be sharing with you how to solve the irritating “serve static content from a cookieless domain” warning.
If you are using Pingdom, this sight is just too common for many:
Disclaimer:
Due to the latest changes with the web and new protocols such as HTTP/2, it is safe to ignore this warning for now. However, I’m still a strong believer that we should find a solution to fix the “serve static content from a cookieless domain” warning if we can.
And yes, this article will show you how.
if we can.
And yes, this article will show you how.
How to fix the “serve static content from a cookieless domain” warning?
Here’s the quick and direct response to your question. In order to serve static content from a cookieless domain, you can either re-configuring your WordPress website or use a Content Delivery Network (or CDN in short).
Solution 1: Re-configure your WordPress website to serve static content from a cookieless domain
This method is free but at the cost of some work and knowledge.
For starters, you need to understand that the way your website is being configured will play a crucial role in the success of this method.
If you use a top-level domain such as domain.com, then you would need to actually use a separate domain altogether. If you are using www.domain.com then you could simply set up a subdomain such as static.domain.com.
As most websites are configured on www.domain.com, the method below is strictly for websites with www:
- Create a subdomain
- You can use any name and I’m using static.domain.com. This is where you will be delivering your files from (and ultimately solving the server static content from cookieless domain warning.
- Point your subdomain to your wp-content directory with a CNAME.
- Not sure what is CNAME? Here’s a quick source for you.
- Edit your wp-config.php file to reflect the following:
define(“WP_CONTENT_URL”, “http://static.domain.com”);
define(“COOKIE_DOMAIN”, “domain.com”);
Not sure where to find wp-config.php file?
The configuration file of your WordPress script is located in the WordPress installation directory and its name is: wp-config.php
You can edit it through cPanel –> File Manager. Find the file, click on it and from the top menu choose “Edit”.
Solution 2: Using CDN to serve static content from a cookieless domain
The fastest solution to serving static content from a cookieless domain is by using a Content Delivery Network.
Here’s the concept: If you offload all your static content to a CDN or a file storage service like MaxCDN, keeping the static file requests cookie-free should be easy as long as you haven’t set up a CNAME record on a subdomain that receives cookies from your top-level domain.
For Google and other search engines, it doesn’t matter the files are hosted on 3rd party servers or your own.
Remember that it is all about the domain that the request is made to and making sure nothing on that domain sets any cookies.
Why use Content Delivery Network such as MaxCDN?
The answer is simple. It is easy and hassle free. You don’t have to crack your head or mess with confusing codes just to serve static content from a cookieless domain.
Besides that, MaxCDN is seriously affordable and apart from solving your static content serving, it also helps you to speed up your website loading speed by the seconds!
Don’t forget that Google gives higher ranking to websites that load faster (and under 1.5 seconds).
Learn more about MaxCDN and click here to get MaxCDN discount.
How to know if you have successfully serve static content from a cookieless domain?
Once you have completed either of the steps above, you would need to clear your browser cache and empty the cache plugin. You may also decide to leave it for a few hours before checking on Pingdom Tools.
You will know it is successful when you see the following: