Use a Content Domain Network (CDN)/Cookie free Domain

Getting Your Resources to Distant Users Faster

Why You Need a CDN/Cookieless Domain

The CDN/Cookieless domain feature is used to load your static files over a CDN, or a cookieless domain. JCH Optimize does this by rewriting the urls of the static files, so they are loaded from the CDN or cookieless domain. When this feature is enabled and configured, the plugin parses the HTML for the urls to all your static files and modify them with the CDN/cookieless domain that was configured. This happens whether it was a relative or absolute url. The following example shows the modified urls if your static domain was static.mydomain.com and your main domain was www.mydomain.com

Example 5.2. Urls to Static Files Modified with CDN Domains

Original Urls. 

<link rel="stylesheet" href="/media/system/css/frontediting.css" type="text/css" />
<script src="/media/jui/js/jquery.min.js" type="text/javascript"></script>
<img src="http://www.mydomain.com/screenshots/rocketlauncher/frontpage/showcase/optimizweb.png" alt="" /> 

Modified Urls. 

 <link rel="stylesheet" href="//static.mydomain.com/media/system/css/frontediting.css" type="text/css" />
<script src="//static.mydomain.com/media/jui/js/jquery.min.js" type="text/javascript"></script>
<img src="//static.mydomain.com/screenshots/rocketlauncher/frontpage/showcase/optimizweb.png" alt="" /> 


A CDN, or Content Delivery Network, is a distributed system of proxy servers that deliver web content to a user based on his geographical location. The CDN copies the files of a website to a network of servers that are dispersed geographically at different locations and the server closest to the user responds to the request. The closer the server is to the user geographically, the faster the content is delivered.

A cookieless domain is a separate domain, sometimes a subdomain, that aliases your main domain, but care is taken not to set any cookies on the cookieless domain. The trouble with cookies is that once your server sets a cookie for your domain, all subsequent HTTP requests to that domain must include the cookie even if the server has no use for the cookie, as in the case of static contents like CSS, JavaScript and image files. By serving your static contents from cookieless domains, you eliminate useless codes from the request headers, improving performance.


Before enabling this feature

In order to use this feature, you need to have the CDN domain for a pull-zone from a CDN provider or have a static cookieless domain set up.


Procedure 5.2. Configuring the CDN/Cookieless Domain feature

  1. Set Up CDN or Cookieless Domain

    Set up your CDN pull-zone or your cookieless domain.

    • Set up CDN

      1. Sign up with a CDN provider that offers pull zones. The following popular CDNs should work with JCH Optimize:

        MaxCDN
        CDNify
        Amazon CloudFront
        KeyCDN

        [Note]Note

        CloudFlare does not work with JCH Optimize in this way. You do not need a plugin to configure CloudFlare. Please refer to their documentation or support to get assistance in configuring CloudFlare.

      2. Refer to your provider's documentation or support to set up your pull zone. They should provide you with a CDN domain that you should request your static resources from. These requests will be pulled from your website, the origin server, and cached and served from their servers.

    • Set up Cookieless Domain

      1. The easiest way to do this is to create a subdomain. You can do this inside cpanel of your web host. Make sure to set the document root of the subdomain to the document root of the website.

        Create Subdomain

        Creating a Subdomain Inside CPanel

        Alternatively you could register a new domain name to use as your static cookieless domain and create a CNAME record in your DNS tables aliasing your static domain to your main domain.

        Create CNAME Record

        Aliasing Static Domain Using CNAME Record

      2. If you used a subdomain, ensure to configure your CMS to set cookies for only www.mydomain.com and not the top-level domain mydomain.com. Refer to your platform's documentation on how to set the cookie domain.

  2. Configure the CDN/Cookieless domain

    Enter the CDN domain or cookieless domain you have set up on the CDN tab on The Options Page and enable the feature. You can also set up multiple domains up to a number of three to parallelize downloads across hostnames. The plugin will alternate between the configured domains when it is modifying the urls of the static files.

    CDN/Cookieless Domain Feature

    Configuring the CDN/Cookieless Domain Feature

  3. Configure file types

    Select the file types that you want to be loaded over the static domain(s). All file types are selected by default.