Getting Your Resources to Distant Users Faster
Why You Need a CDN/Cookieless Domain
CDN/Cookieless domain feature, found on the Pro Features tab, is used to load your static files over a CDN, or a cookieless domain. The plugin 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 4.1. Urls to Static Files Modified with CDN Domains
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.
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. Additionally, this feature is only available in the pro version of the plugin so if you haven't already, now is a good time to subscribe for JCH Optimize Pro.
Procedure 4.2. Configuring the CDN/Cookieless Domain feature
Set Up CDN or Cookieless Domain
Set up your CDN pull-zone or your cookieless domain.
Set up CDN
Sign up with a CDN provider that offers pull zones. The following popular CDNs should work with JCH Optimize:
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.
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
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.
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.
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.
Enter the configured CDN domain or cookieless domain and enable the feature. You can also set up multiple domains up to a number of three to parralelize downloads across hostnames. The plugin will alternate between the configured domains when it is modifying the urls of the static files.
Select the file types that you want to be loaded over the static domain(s). All file types are selected by default.