Fix “Serve Static Content From a Cookieless Domain” Warning
Pingdom, GTmetrix, or Google PageSpeed Insights are telling you to “serve static content from a cookieless domain.” When providing content like photos, JavaScript, or CSS, an HTTP cookie is usually unnecessary because it adds overhead. Once a cookie is set for a domain, the cookie must be included in all subsequent HTTP requests for that domain.
This message is usually displayed on sites that receive a great number of requests. Using a CDN provider that strips cookies or setting up a separate domain and or subdomain to deliver cookies are two options.
Info
This warning can now typically be safely disregarded due to recent modifications to the web and new protocols such as HTTP/2. A new connection is frequently more expensive than streaming everything over the existing one. With parallelism, HTTP/2 can now achieve incredible results. And, in general, cookies are quite little.
The warning may appear in one of two ways, depending on the tool or software that generated it:
“provide the following static pages from a non-cookie-setting domain”
“provide static material from a domain that doesn’t use cookies”
pingdom provide static content from a domain that doesn’t use cookies
warning: serve static content from a cookieless domain
However, if you still wish to serve cookies from a separate domain, follow the instructions below.
Fix Serve Static Content From a Cookie less Domain Warning
Using a CDN and re-configuring your WordPress site are two options for resolving the “serve static content from a cookieless website” issue.
Reconfigure your WordPress site with a CDN 1. Use a content delivery network (CDN).
One simple solution is to utilize a CDN provider that may ignore or strip cookies, therefore preventing the client from obtaining the Set-Cookie response header. This capability is available from one CDN provider, Key CDN. As you can see, the following two settings are activated by default. This is a simple alternative to relocating and configuring your website to distribute static files from a different subdomain. cookies from cdn
Note that you cannot disable cookies on Cloudflare-served resources. In your header, Cloudflare additionally includes its own security cookie. Again, these cookies are quite little, and their impact on performance is negligible. However, there is no way to avoid this warning if you use Cloudflare.
2. Make a change to your WordPress site’s settings
The second approach is to re-configure your WordPress site such that static assets are sent from a different domain or subdomain. Note that if you use a top-level domain like domain.com, you’ll need to use a different domain altogether. If you’re using www.domain.com, you can just create a subdomain called static.domain.com. We’ll assume your website’s address is www.domain.com in this example.
Create a subdomain like static.domain.com first. This is where you’ll send all of your files.
Create a CNAME record for your subdomain that points to your main domain.
By modifying the wp-config.php file, you may point your subdomain to your /wp-content directory:
define(“WP CONTENT URL”, “http://static.domain.com”); define(“COOKIE DOMAIN”, “domain.com”); define(“WP CONTENT URL”, “http://static.domain.com”); define(“WP CONTENT URL”, “http://static.domain.com”); define
Save time, money, and improve site performance by using:
Expert WordPress hosting assistance is available 24 hours a day, 7 days a week.
Integration with Cloudflare Enterprise.
With 29 data centers across the world, we can reach a global audience.
With our built-in Application Performance Monitoring, you can improve your performance.
All of this and more is included in a single plan that includes no long-term obligations, aided migrations, and a 30-day money-back guarantee. Check out our plans or speak with a sales representative to find the ideal plan for you.