Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Fix the "Serve Static Content From a Cookieless Domain" Warning

Speed tools flag this when images, CSS and scripts are sent with cookies they do not need. A CDN or a separate domain solves it.

Speed and Performance2 min read7 steps2 screenshots

What the warning means

Every request to your domain carries its cookies. For static files (images, CSS, JavaScript) the cookies are not needed, but they still add data to every request. Speed tests warn you to serve static files from a domain that sets no cookies.

Benefits

  1. Less data in each request, so pages load faster.
  2. Better speed scores, which also help SEO.
  3. Better caching. Browsers and proxies can cache the static files more easily.
  4. Less load on your main server.

Fix 1: Use a CDN

A content delivery network (CDN) serves your static files from its own domain and servers, with no cookies.

  1. Sign up for a CDN, for example Cloudflare, BunnyCDN or KeyCDN (many have a free plan).
  2. Connect it to your site. In WordPress, a plugin such as WP Super Cache, W3 Total Cache or the CDN's own plugin does it for you.
  3. Enter the CDN address (for example cdn.example.com) in the plugin settings.
    CDN settings in a plugin

Fix 2: Use a separate subdomain

Make a subdomain such as static.example.com that points to the same files, and serve the static content from it.

In WordPress, set the content URL and the cookie domain in wp-config.php:

define("WP_CONTENT_URL", "http://static.example.com");
define("COOKIE_DOMAIN", "www.example.com");
Constants in wp-config.php

Setting COOKIE_DOMAIN to the main host name keeps the cookies from going to the static subdomain.

Note: Use a full domain that does not share cookies with the static one. A cookie set for .example.com is sent to all subdomains.

Which one to choose

  • A busy site gains much from a CDN.
  • Most CDNs have a free plan. Pay for more features only when you need them.
  • A subdomain is a good start for a small site.

More ways to speed up static files

  • Compress images without losing quality.
  • Set Cache-Control headers for static files.
  • Minify and compress CSS and JavaScript.
  • Turn on Gzip or Brotli compression on the server.

Quick recap

  • Cookies add weight to static requests.
  • Serve static files from a CDN or a cookieless subdomain.
  • Combine it with caching and compression.