How to Fix “Serve Static Content From a Cookieless Domain” Warning


Seeing the “serve static content from a cookieless domain” warning in Pingdom, GTmetrix, or Google PageSpeed Insights? Generally, when you are serving content such as images, JavaScript, CSS, there is no reason for an HTTP cookie to accompany it, as it creates additional overhead. Once the server sets a cookie for a particular domain, all subsequent HTTP requests for that domain must include the cookie.

This warning is typically seen on sites with a large number of requests. Some ways to fix this include using a CDN provider that strips cookies or set up a separate domain and or subdomain to serve cookies.

Depending upon the tool or software reporting it, the warning might appear in a couple of different ways:

  • “serve the following static resources from a domain that doesn’t set cookies”
  • “serve static content from a cookieless domain”
pingdom serve static content from a cookieless domain
Serve static content from a cookieless domain warning

But if you still want to set up a separate domain to serve up cookies, here are the directions below.

Fix Serve Static Content From a Cookieless Domain Warning

There are a couple of ways to fix the “serve static content from a cookieless domain” warning, such as using a CDN and also re-configuring your WordPress site.

  1. Use a CDN
  2. Re-Configure WordPress Site

1. Use a CDN

One easy way to fix this warning is to use a CDN provider that has the ability to ignore cookies as well as strip cookies which will completely prevent the client from receiving the Set-Cookie response header. KeyCDN is one CDN provider that does offer this feature. By default, you can see the following two options are enabled. This is an easy alternative without having to mess with moving and configuring your site to deliver static assets from a separate subdomain.cdn strip cookies

Note: You cannot disable cookies on resources served through CloudFlare. CloudFlare also includes its own security cookie in your header. Again these cookies are very small and the performance implications are extremely minimal. But if you use CloudFlare, there is no way to get around this warning.

2. Re-Configure WordPress Site

The second option you have is to re-configure your WordPress site to deliver the static assets from a new domain or subdomain. Note: 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. In this example, we will assume your website is on www.domain.com.

  1. First, create a subdomain such as static.domain.com. This is where you will deliver all your files from.
  2. Set up your subdomain’s DNS record as a CNAME pointing to your main domain.
  3. Point your subdomain to your /wp-content directory by editing your wp-config.php file:
    define("WP_CONTENT_URL", "http://static.domain.com"); 
    define("COOKIE_DOMAIN", "domain.com");

Save time, costs and maximize site performance with:

  • Instant help from WordPress hosting experts, 24/7.
  • Cloudflare Enterprise integration.
  • Global audience reach with 34 data centers worldwide.
  • Optimization with our built-in Application Performance Monitoring.

All of that and much more, in one plan with no long-term contracts, assisted migrations, and a 30-day-money-back-guarantee. Check out our plans or talk to sales to find the plan that’s right for you.

Jaspreet Singh Ghuman

Jaspreet Singh Ghuman

Jassweb.com/

Passionate Professional Blogger, Freelancer, WordPress Enthusiast, Digital Marketer, Web Developer, Server Operator, Networking Expert. Empowering online presence with diverse skills.

jassweb logo

Jassweb always keeps its services up-to-date with the latest trends in the market, providing its customers all over the world with high-end and easily extensible internet, intranet, and extranet products.

Contact
San Vito Al Tagliamento 33078
Pordenone Italy
Item added to cart.
0 items - 0.00
Open chat
Scan the code
Hello 👋
Can we help you?