Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to solve [Serve the following static resources from a domain that doesn't set cookies]

I'm struggling in something i don't know at all. When the time i ping my website, i got this result: [Serve the following static resources from a domain that doesn't set cookies:]. And, this result caused from the images which i used for background images. I tried to google about this topic but all the answers seem to be difficult to understand of. Does anyone here knows about it and any simple solution to fix it up?

like image 216
Jornes Avatar asked Jun 11 '16 01:06

Jornes


People also ask

How do I resolve cookie-free domains?

The following steps outline how to use cookie-free domains in WordPress: Create a subdomain, such as static.yourwebsite.com , which is where you will deliver all your static files from. Point your new subdomain to the /wp-content directory of your WordPress installation.

How do I disable cookies in IIS?

In IIS, go to the Home Directory tab, then click the "Configuration" button. Next go to the Options tab and un-check "Enable session state". The cookie will go away, and you can leave your files where they are with no need for an extra domain or sub-doamin.

What is cookie less domain?

Any website needs a cookie-less domain. This (sub)domain is typically called “static”. It is used to serve Javascript, CSS, images and other static content. The reason for static content to be on a cookie-less domain is that it makes the content load faster.


1 Answers

Generally, when you are serving content such as images, JavaScript, CSS, there is no reason for a HTTP cookie to accompany it, as it creates additional overhead. That is why a lot of tools report this. Here are two quick and easy options:

Option 1 - Use a CDN

Use a CDN to host your images which has the ability to ignore cookies as well as strip cookies which will completely prevent the client from receiving the Set-Cookie response header. Note: You can't disable cookies on Cloudflare.

Option 2 - Point Static Assets to New Domain

This is an example with WordPress.

  1. First, create a subdomain such as static.domain.com. This is where you will deliver all your files from.
  2. Point your subdomain to your /wp-content directory with a CNAME.
  3. Edit your wp-config.php file to reflect the following:

define("WP_CONTENT_URL", "http://static.domain.com"); 
define("COOKIE_DOMAIN", "domain.com");

See more in this post on how to fix the Serve Static Content From a Cookieless Domain warning.

like image 142
Brian Jackson Avatar answered Nov 15 '22 10:11

Brian Jackson