{"id":853,"date":"2017-12-15T05:51:56","date_gmt":"2017-12-15T05:51:56","guid":{"rendered":"http:\/\/stackofcodes.in\/?p=853"},"modified":"2017-12-15T05:51:56","modified_gmt":"2017-12-15T05:51:56","slug":"how-to-setup-a-cdn-to-speed-up-your-website","status":"publish","type":"post","link":"https:\/\/www.chandansharma.co.in\/blog\/how-to-setup-a-cdn-to-speed-up-your-website\/","title":{"rendered":"HOW TO SETUP A CDN TO SPEED UP YOUR WEBSITE"},"content":{"rendered":"<h2 class=\"post-title\"><i>HOW TO SETUP A CDN TO SPEED UP YOUR WEBSITE::<\/i><\/h2>\n<div><i>\u00a0<\/i><\/div>\n<div><i>\u00a0<\/i><\/div>\n<div>\n<div class=\"main_content\">\n<div>If you\u2019re looking for ways to speed up your website, one of the best is to setup a CDN. You can think of a\u00a0<a title=\"What is a Content Delivery Network - Wikipedia\" href=\"http:\/\/en.wikipedia.org\/wiki\/Content_delivery_network\" target=\"_blank\" rel=\"noopener\">Content Delivery Network<\/a>\u00a0as a service that hosts your website\u2019s static files and delivers them to the client instead of your own web server. Direct benefits of this are reduced load on your own server and faster download times for the client. Sounds good? Let\u2019s get to it.<\/div>\n<h3>Considerations<\/h3>\n<div>This how-to will offer some high level tips and tricks that should apply to any web project. Some specifics will be shown in the examples, but this is definitely not a copy-and-paste solution that will solve your CDN ambitions.<\/div>\n<h3>The Basics<\/h3>\n<div>First you need a basic understanding of how to integrate a CDN into your website. It\u2019s simple really: for any static resource you serve up, replace its URL with the URL of the same resource on the CDN.<br \/>\nFor example:\u00a0<span id=\"crayon-5a30cf55809c0151955527\" class=\"crayon-syntax crayon-syntax-inline  crayon-theme-classic crayon-theme-classic-inline crayon-font-droid-sans-mono\"><span class=\"crayon-pre crayon-code\"><span class=\"crayon-v\">http<\/span><span class=\"crayon-o\">:<\/span><span class=\"crayon-c\">\/\/mywebsite.com\/img\/logo.png<\/span><\/span><\/span><br \/>\nbecomes<span id=\"crayon-5a30cf55809cd577900930\" class=\"crayon-syntax crayon-syntax-inline  crayon-theme-classic crayon-theme-classic-inline crayon-font-droid-sans-mono\"><span class=\"crayon-pre crayon-code\"><span class=\"crayon-v\">http<\/span><span class=\"crayon-o\">:<\/span><span class=\"crayon-c\">\/\/cdn.mycdnprovider.com\/img\/logo.png<\/span><\/span><\/span>\u00a0.<\/p>\n<p>This means that your CDN provider will need to host\u00a0<em>logo.png;<\/em>\u00a0let\u2019s talk about that next.<\/div>\n<div>The CDN hosts your static resources so somehow your files must be loaded onto its network. There are two ways this usually happens: You upload the files manually, or the CDN fetches the files automatically from an\u00a0<em>origin server<\/em>. With the latter method, there\u2019s no reason why the origin server can\u2019t also be your web server. With both methods, the resources persist until they\u2019re updated. This means that if you modify\u00a0<em>logo.png<\/em>\u00a0you must update its corresponding resource on the CDN, otherwise the old, unmodified version will continue to be delivered. You can almost think of the CDN as a type of cache that needs to be invalidated when the source changes. Regardless, there\u2019s no doubt you\u2019ll be making updates to your CSS, JS and images so you need to consider how you\u2019ll easily update the CDN. Don\u2019t worry \u2013 we\u2019ll cover a simple, yet elegant solution for this.<\/div>\n<\/div>\n<\/div>\n<div><\/div>\n<div><\/div>\n<div>\n<h3>Getting Started<\/h3>\n<div>\n<div>You\u2019re going to see immediate performance improvements by serving up your images, JS and CSS through your CDN so we\u2019ll focus on these. You\u2019ll want to set up some sort of convention that makes it easy to interchange URLs within your code. Basically, whenever you output a URL, use your CDN instead.<\/div>\n<div><\/div>\n<pre><em><strong>index.php::<\/strong><\/em>\n\n\n&lt;?php define('CDN', 'http:\/\/cdn.mycdnprovider.com\/'); ?&gt;\n&lt;html&gt; \n&lt;head&gt; \n&lt;script type='text\/javascript'&gt;\n \/* A javascript global for using the CDN inside scripts *\/ \nvar CDN = '&lt;?php echo CDN ?&gt;'; \n&lt;\/script&gt; \n\n&lt;!-- (generated server side from less\/style.less) --&gt; \n\n&lt;link rel='stylesheet' href='&lt;?php echo CDN ?&gt;css\/style.css' \/&gt; \n&lt;\/head&gt; \n&lt;body&gt; \n&lt;img src='&lt;?php echo CDN ?&gt;img\/logo.png' \/&gt; \n&lt;button&gt;Submit&lt;\/button&gt; \n&lt;script type='text\/javascript' src='&lt;?php echo CDN ?&gt;js\/main.js'&gt;&lt;\/script&gt; &lt;\/body&gt;\n&lt;\/html&gt;\n\n<em><strong>js\/main.js<\/strong><\/em>\n\n(function() {\n\u00a0 \u00a0 var preloadImage = document.createElement('img');\n\u00a0 \u00a0 preloadImage.src = CDN + 'img\/button_hover.png';\n\n})();\n\n\n<\/pre>\n<\/div>\n<div>\n<div>As you can see in the PHP and Javascript snippets above, it\u2019s as simple as using a global prefix in front of all your relative URLs. But what about CSS? There\u2019s no such thing as CSS variables, which is why you should never write vanilla CSS. If you don\u2019t already use either\u00a0<a title=\"Syntactically Awesome Stylesheets\" href=\"http:\/\/sass-lang.com\/\" target=\"_blank\" rel=\"noopener\">SASS<\/a>\u00a0or\u00a0<a title=\"The dynamic stylesheet language\" href=\"http:\/\/lesscss.org\/\" target=\"_blank\" rel=\"noopener\">LessCSS<\/a>, then make the switch \u2013 NOW! We prefer LESS, so here\u2019s how to set up your styles.<\/div>\n<\/div>\n<\/div>\n<div><\/div>\n<div>\n<div>\n<pre><em><strong>style.less<\/strong><\/em>\n\n\n@CDN: 'http:\/\/cdn.mycdnprovider.com\/';\n\nbutton {\n\n\u00a0 \u00a0 background-image: url('@{CDN}img\/button.png');\n\n\u00a0 \u00a0 &amp;:hover {\n\n\u00a0 \u00a0 \u00a0 \u00a0 background-image: url('@{CDN}img\/button_hover.png');\n\n\u00a0 \u00a0 }\n\n}<\/pre>\n<\/div>\n<div>You should now have full control over the URLs used to serve up static content to the client. If you want to disable the CDN, you only need to set\u00a0<span id=\"crayon-5a30cf55809f3676031901\" class=\"crayon-syntax crayon-syntax-inline  crayon-theme-classic crayon-theme-classic-inline crayon-font-droid-sans-mono\"><span class=\"crayon-pre crayon-code\"><span class=\"crayon-v\">CDN<\/span><span class=\"crayon-h\">\u00a0<\/span><span class=\"crayon-o\">=<\/span><span class=\"crayon-h\">\u00a0<\/span><span class=\"crayon-s\">&#8216;\/&#8217;<\/span><span class=\"crayon-sy\">;<\/span><\/span><\/span>\u00a0and resources will be pulled from your server.<\/div>\n<h3>Server Configuration<\/h3>\n<div>This might be enough to satisfy you, but there\u2019s more. Most projects have three environments \u2013 local\/dev, staging\/testing and live\/production so you should have a method to configure which CDN server is used based on the environment. You likely don\u2019t want to use any CDN on your dev server and your testing server should use a different CDN from the production server to avoid versioning conflicts (discussed later). So all you need are a few configuration files. (The following example is using the\u00a0<a title=\"CakePHP makes building web applications simpler, faster and require less code.\" href=\"http:\/\/cakephp.org\/\" target=\"_blank\" rel=\"noopener\">CakePHP<\/a>\u00a0framework)<\/div>\n<div id=\"crayon-5a30cf55809fb279577922\" class=\"crayon-syntax crayon-theme-classic crayon-font-droid-sans-mono crayon-os-pc print-yes notranslate\">\n<div class=\"crayon-toolbar\"><span class=\"crayon-title\">app\/Config\/cdn.php<\/span><\/p>\n<div class=\"crayon-tools\"><span class=\"crayon-language\">PHP<\/span><\/div>\n<\/div>\n<div class=\"crayon-plain-wrap\"><\/div>\n<div class=\"crayon-main\">\n<table class=\"crayon-table\">\n<tbody>\n<tr class=\"crayon-row\">\n<td class=\"crayon-nums \">\n<div class=\"crayon-nums-content\">\n<div class=\"crayon-num\">1<\/div>\n<div class=\"crayon-num crayon-striped-num\">2<\/div>\n<div class=\"crayon-num\">3<\/div>\n<div class=\"crayon-num crayon-striped-num\">4<\/div>\n<div class=\"crayon-num\">5<\/div>\n<div class=\"crayon-num crayon-striped-num\">6<\/div>\n<\/div>\n<\/td>\n<td class=\"crayon-code\">\n<div class=\"crayon-pre\">\n<div id=\"crayon-5a30cf55809fb279577922-1\" class=\"crayon-line\"><span class=\"crayon-ta\">&lt;?php<\/span><\/div>\n<div id=\"crayon-5a30cf55809fb279577922-2\" class=\"crayon-line crayon-striped-line\"><span class=\"crayon-c\">\/\/ A CakePHP configuration file<\/span><\/div>\n<div id=\"crayon-5a30cf55809fb279577922-3\" class=\"crayon-line\"><span class=\"crayon-v\">$config<\/span> <span class=\"crayon-o\">=<\/span> <span class=\"crayon-t\">array<\/span><span class=\"crayon-sy\">(<\/span><\/div>\n<div id=\"crayon-5a30cf55809fb279577922-4\" class=\"crayon-line crayon-striped-line\"><span class=\"crayon-h\">\u00a0\u00a0\u00a0\u00a0<\/span><span class=\"crayon-s\">&#8216;CDN&#8217;<\/span> <span class=\"crayon-o\">=<\/span><span class=\"crayon-o\">&gt;<\/span> <span class=\"crayon-t\">array<\/span><span class=\"crayon-sy\">(<\/span><span class=\"crayon-s\">&#8216;path&#8217;<\/span> <span class=\"crayon-o\">=<\/span><span class=\"crayon-o\">&gt;<\/span> <span class=\"crayon-s\">&#8216;http:\/\/cdn.mycdnprovider.com\/&#8217;<\/span><span class=\"crayon-sy\">)<\/span><\/div>\n<div id=\"crayon-5a30cf55809fb279577922-5\" class=\"crayon-line\"><span class=\"crayon-sy\">)<\/span><span class=\"crayon-sy\">;<\/span><\/div>\n<div id=\"crayon-5a30cf55809fb279577922-6\" class=\"crayon-line crayon-striped-line\"><span class=\"crayon-ta\">?&gt;<\/span><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<div><\/div>\n<div id=\"crayon-5a30cf5580a02904800951\" class=\"crayon-syntax crayon-theme-classic crayon-font-droid-sans-mono crayon-os-pc print-yes notranslate\">\n<div class=\"crayon-toolbar\"><span class=\"crayon-title\">bootstrap.php<\/span><\/p>\n<div class=\"crayon-tools\"><span class=\"crayon-language\">PHP<\/span><\/div>\n<\/div>\n<div class=\"crayon-plain-wrap\"><\/div>\n<div class=\"crayon-main\">\n<table class=\"crayon-table\">\n<tbody>\n<tr class=\"crayon-row\">\n<td class=\"crayon-nums \">\n<div class=\"crayon-nums-content\">\n<div class=\"crayon-num\">1<\/div>\n<div class=\"crayon-num crayon-striped-num\">2<\/div>\n<div class=\"crayon-num\">3<\/div>\n<div class=\"crayon-num crayon-striped-num\">4<\/div>\n<\/div>\n<\/td>\n<td class=\"crayon-code\">\n<div class=\"crayon-pre\">\n<div id=\"crayon-5a30cf5580a02904800951-1\" class=\"crayon-line\"><span class=\"crayon-sy\">.<\/span><span class=\"crayon-sy\">.<\/span><span class=\"crayon-sy\">.<\/span><\/div>\n<div id=\"crayon-5a30cf5580a02904800951-2\" class=\"crayon-line crayon-striped-line\"><span class=\"crayon-e\">Configure::<\/span><span class=\"crayon-e\">load<\/span><span class=\"crayon-sy\">(<\/span><span class=\"crayon-s\">&#8216;cdn&#8217;<\/span><span class=\"crayon-sy\">)<\/span><span class=\"crayon-sy\">;<\/span><\/div>\n<div id=\"crayon-5a30cf5580a02904800951-3\" class=\"crayon-line\"><span class=\"crayon-e\">define<\/span><span class=\"crayon-sy\">(<\/span><span class=\"crayon-s\">&#8216;CDN&#8217;<\/span><span class=\"crayon-sy\">,<\/span> <span class=\"crayon-e\">Configure::<\/span><span class=\"crayon-e\">read<\/span><span class=\"crayon-sy\">(<\/span><span class=\"crayon-s\">&#8216;CDN.path&#8217;<\/span><span class=\"crayon-sy\">)<\/span><span class=\"crayon-sy\">)<\/span><span class=\"crayon-sy\">;<\/span><\/div>\n<div id=\"crayon-5a30cf5580a02904800951-4\" class=\"crayon-line crayon-striped-line\"><span class=\"crayon-sy\">.<\/span><span class=\"crayon-sy\">.<\/span><span class=\"crayon-sy\">.<\/span><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<div><\/div>\n<div id=\"crayon-5a30cf5580a08252210170\" class=\"crayon-syntax crayon-theme-classic crayon-font-droid-sans-mono crayon-os-pc print-yes notranslate\">\n<div class=\"crayon-toolbar\"><span class=\"crayon-title\">less\/cdn.less<\/span><\/p>\n<div class=\"crayon-tools\"><span class=\"crayon-language\">LESS<\/span><\/div>\n<\/div>\n<div class=\"crayon-plain-wrap\"><\/div>\n<div class=\"crayon-main\">\n<table class=\"crayon-table\">\n<tbody>\n<tr class=\"crayon-row\">\n<td class=\"crayon-nums \">\n<div class=\"crayon-nums-content\">\n<div class=\"crayon-num\">1<\/div>\n<\/div>\n<\/td>\n<td class=\"crayon-code\">\n<div class=\"crayon-pre\">\n<div id=\"crayon-5a30cf5580a08252210170-1\" class=\"crayon-line\"><span class=\"crayon-v\">@CDN<\/span><span class=\"crayon-sy\">:<\/span> <span class=\"crayon-s\">&#8216;http:\/\/cdn.mycdnprovider.com\/&#8217;<\/span><span class=\"crayon-sy\">;<\/span><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<div><\/div>\n<div id=\"crayon-5a30cf5580a0e034157303\" class=\"crayon-syntax crayon-theme-classic crayon-font-droid-sans-mono crayon-os-pc print-yes notranslate\">\n<div class=\"crayon-toolbar\"><span class=\"crayon-title\">style.less<\/span><\/p>\n<div class=\"crayon-tools\"><span class=\"crayon-language\">LESS<\/span><\/div>\n<\/div>\n<div class=\"crayon-plain-wrap\"><\/div>\n<div class=\"crayon-main\">\n<table class=\"crayon-table\">\n<tbody>\n<tr class=\"crayon-row\">\n<td class=\"crayon-nums \">\n<div class=\"crayon-nums-content\">\n<div class=\"crayon-num\">1<\/div>\n<div class=\"crayon-num crayon-striped-num\">2<\/div>\n<\/div>\n<\/td>\n<td class=\"crayon-code\">\n<div class=\"crayon-pre\">\n<div id=\"crayon-5a30cf5580a0e034157303-1\" class=\"crayon-line\"><span class=\"crayon-n\">@import &#8216;cdn&#8217;;<\/span><\/div>\n<div id=\"crayon-5a30cf5580a0e034157303-2\" class=\"crayon-line crayon-striped-line\"><span class=\"crayon-c\">\/* @CDN defined above, the rest of your LESS below *\/<\/span><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<div>The configuration files above shouldn\u2019t be checked into version control because they\u2019re presumably different from server to server. Instead, check in defaults such as\u00a0<span id=\"crayon-5a30cf5580a15080477946\" class=\"crayon-syntax crayon-syntax-inline  crayon-theme-classic crayon-theme-classic-inline crayon-font-droid-sans-mono\"><span class=\"crayon-pre crayon-code\"><span class=\"crayon-v\">cdn<\/span><span class=\"crayon-sy\">.<\/span><span class=\"crayon-v\">php<\/span><span class=\"crayon-sy\">.<\/span><span class=\"crayon-st\">default<\/span><\/span><\/span>\u00a0and\u00a0<span id=\"crayon-5a30cf5580a1c318961026\" class=\"crayon-syntax crayon-syntax-inline  crayon-theme-classic crayon-theme-classic-inline crayon-font-droid-sans-mono\"><span class=\"crayon-pre crayon-code\"><span class=\"crayon-v\">cdn<\/span><span class=\"crayon-sy\">.<\/span><span class=\"crayon-v\">less<\/span><span class=\"crayon-sy\">.<\/span><span class=\"crayon-st\">default<\/span><\/span><\/span>, with the intention that the developer deploying the code to the server for the first time will create the required config files with the server-specific settings.<\/div>\n<\/div>\n<div><\/div>\n<div>\n<div class=\"main_content\">\n<h3>Versioning &amp; Resource Invalidation<\/h3>\n<div>As mentioned in the\u00a0<i>Basics\u00a0<\/i>section, you\u2019re likely to deploy multiple releases of your static files. Most CDNs use some sort of TTL to invalidate resources, but if you want full control, you\u2019re better off to version your resources. If you\u2019re using Amazon\u2019s CloudFront CDN service, here is a good discussion on\u00a0<a title=\"Amzaon CloudFront Resource Invalidation\" href=\"http:\/\/docs.aws.amazon.com\/AmazonCloudFront\/latest\/DeveloperGuide\/Invalidation.html\" target=\"_blank\" rel=\"noopener\">resource invalidation<\/a>. This essentially means that instead of modifying\u00a0<em>logo.png<\/em>, you create a new file called\u00a0<em>logo_ver2.png<\/em>\u00a0or put a copy in a versioned folder such as\u00a0<em>\/resources_ver2\/<\/em>. However, that would be a nightmare to manage wouldn\u2019t it?<\/div>\n<div>We previously mentioned that you can configure your CDN to fetch resources from an\u00a0<em>origin server<\/em>. If you use the versioned folder solution for the invalidation problem, your URLs would look something like this:\u00a0\u00a0<span id=\"crayon-5a30cf5580a24371510958\" class=\"crayon-syntax crayon-syntax-inline  crayon-theme-classic crayon-theme-classic-inline crayon-font-droid-sans-mono\"><span class=\"crayon-pre crayon-code\"><span class=\"crayon-v\">http<\/span><span class=\"crayon-o\">:<\/span><span class=\"crayon-c\">\/\/cdn.mycdnprovider.com\/ver-1.0.0\/img\/logo.png<\/span><\/span><\/span>. To invalidate\u00a0<em>logo.pn<\/em><em>g<\/em>\u00a0you would increment the version number to\u00a0<em>1.0.1\u00a0<\/em>thereby forcing the CDN to fetch a\u00a0<em>different<\/em>\u00a0copy of the resource. With a simple URL Rewrite, our web server can spoof the version number in the URL and deliver\u00a0<em>logo.png<\/em>\u00a0from the same path on the server.<\/div>\n<div id=\"crayon-5a30cf5580a2f367894846\" class=\"crayon-syntax crayon-theme-classic crayon-font-droid-sans-mono crayon-os-pc print-yes notranslate\">\n<div class=\"crayon-toolbar\"><span class=\"crayon-title\">.htaccess<\/span><\/p>\n<div class=\"crayon-tools\"><\/div>\n<\/div>\n<div class=\"crayon-plain-wrap\"><\/div>\n<div class=\"crayon-main\">\n<table class=\"crayon-table\">\n<tbody>\n<tr class=\"crayon-row\">\n<td class=\"crayon-nums \">\n<div class=\"crayon-nums-content\">\n<div class=\"crayon-num\">1<\/div>\n<div class=\"crayon-num crayon-striped-num\">2<\/div>\n<div class=\"crayon-num\">3<\/div>\n<div class=\"crayon-num crayon-marked-num crayon-top crayon-bottom crayon-striped-num\">4<\/div>\n<div class=\"crayon-num\">5<\/div>\n<div class=\"crayon-num crayon-striped-num\">6<\/div>\n<div class=\"crayon-num\">7<\/div>\n<div class=\"crayon-num crayon-striped-num\">8<\/div>\n<\/div>\n<\/td>\n<td class=\"crayon-code\">\n<div class=\"crayon-pre\">\n<div id=\"crayon-5a30cf5580a2f367894846-1\" class=\"crayon-line\">&lt;IfModule mod_rewrite.c&gt;<\/div>\n<div id=\"crayon-5a30cf5580a2f367894846-2\" class=\"crayon-line crayon-striped-line\">RewriteEngine On<\/div>\n<div id=\"crayon-5a30cf5580a2f367894846-3\" class=\"crayon-line\">RewriteBase \/<\/div>\n<div id=\"crayon-5a30cf5580a2f367894846-4\" class=\"crayon-line crayon-marked-line crayon-top crayon-bottom crayon-striped-line\">RewriteRule ^ver-[0-9]+.[0-9]+.[0-9]+(.*)$ $1 [L,NC]<\/div>\n<div id=\"crayon-5a30cf5580a2f367894846-5\" class=\"crayon-line\">RewriteCond %{REQUEST_FILENAME} !-d<\/div>\n<div id=\"crayon-5a30cf5580a2f367894846-6\" class=\"crayon-line crayon-striped-line\">RewriteCond %{REQUEST_FILENAME} !-f<\/div>\n<div id=\"crayon-5a30cf5580a2f367894846-7\" class=\"crayon-line\">RewriteRule ^(.*)$ index.php?\/$1 [QSA,L]<\/div>\n<div id=\"crayon-5a30cf5580a2f367894846-8\" class=\"crayon-line crayon-striped-line\">&lt;\/IfModule&gt;<\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<div>This little piece of magic makes it a cinch to invalidate any resource without duplicating it. The CDN and the client browser think they\u2019re downloading from some versioned folder, but we know better, don\u2019t we!<\/div>\n<h3>More Configuration<\/h3>\n<div>You might be tempted to just modify your existing CDN configuration files to include a version number. This would work, but to keep your code and framework modular it\u2019s best to have a separate VERSION config file. You\u2019ll want to check this file into version control, especially if you have multiple developers working on the same project. You\u2019ll have to come up with some sort of scheme as to when you increment the VERSION number, but that\u2019s out of the scope of this discussion. Create your version files and make use of them:<\/div>\n<div id=\"crayon-5a30cf5580a38758436017\" class=\"crayon-syntax crayon-theme-classic crayon-font-droid-sans-mono crayon-os-pc print-yes notranslate\">\n<div class=\"crayon-toolbar\"><span class=\"crayon-title\">VERSION<\/span><\/p>\n<div class=\"crayon-tools\"><\/div>\n<\/div>\n<div class=\"crayon-plain-wrap\"><\/div>\n<div class=\"crayon-main\">\n<table class=\"crayon-table\">\n<tbody>\n<tr class=\"crayon-row\">\n<td class=\"crayon-nums \">\n<div class=\"crayon-nums-content\">\n<div class=\"crayon-num\">1<\/div>\n<\/div>\n<\/td>\n<td class=\"crayon-code\">\n<div class=\"crayon-pre\">\n<div id=\"crayon-5a30cf5580a38758436017-1\" class=\"crayon-line\">1.0.0<\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<div><\/div>\n<div id=\"crayon-5a30cf5580a45153026120\" class=\"crayon-syntax crayon-theme-classic crayon-font-droid-sans-mono crayon-os-pc print-yes notranslate\">\n<div class=\"crayon-toolbar\"><span class=\"crayon-title\">bootstrap.php<\/span><\/p>\n<div class=\"crayon-tools\"><span class=\"crayon-language\">PHP<\/span><\/div>\n<\/div>\n<div class=\"crayon-plain-wrap\"><\/div>\n<div class=\"crayon-main\">\n<table class=\"crayon-table\">\n<tbody>\n<tr class=\"crayon-row\">\n<td class=\"crayon-nums \">\n<div class=\"crayon-nums-content\">\n<div class=\"crayon-num\">1<\/div>\n<div class=\"crayon-num crayon-striped-num\">2<\/div>\n<div class=\"crayon-num\">3<\/div>\n<div class=\"crayon-num crayon-striped-num\">4<\/div>\n<div class=\"crayon-num\">5<\/div>\n<\/div>\n<\/td>\n<td class=\"crayon-code\">\n<div class=\"crayon-pre\">\n<div id=\"crayon-5a30cf5580a45153026120-1\" class=\"crayon-line\"><span class=\"crayon-sy\">.<\/span><span class=\"crayon-sy\">.<\/span><span class=\"crayon-sy\">.<\/span><\/div>\n<div id=\"crayon-5a30cf5580a45153026120-2\" class=\"crayon-line crayon-striped-line\"><span class=\"crayon-e\">Configure::<\/span><span class=\"crayon-e\">load<\/span><span class=\"crayon-sy\">(<\/span><span class=\"crayon-s\">&#8216;cdn&#8217;<\/span><span class=\"crayon-sy\">)<\/span><span class=\"crayon-sy\">;<\/span><\/div>\n<div id=\"crayon-5a30cf5580a45153026120-3\" class=\"crayon-line\"><span class=\"crayon-e\">define<\/span><span class=\"crayon-sy\">(<\/span><span class=\"crayon-s\">&#8216;VERSION&#8217;<\/span><span class=\"crayon-sy\">,<\/span> <span class=\"crayon-e\">file_get_contents<\/span><span class=\"crayon-sy\">(<\/span><span class=\"crayon-cn\">APP<\/span><span class=\"crayon-sy\">.<\/span><span class=\"crayon-cn\">DS<\/span><span class=\"crayon-sy\">.<\/span><span class=\"crayon-s\">&#8220;Config&#8221;<\/span><span class=\"crayon-sy\">.<\/span><span class=\"crayon-cn\">DS<\/span><span class=\"crayon-sy\">.<\/span><span class=\"crayon-s\">&#8220;VERSION&#8221;<\/span><span class=\"crayon-sy\">)<\/span><span class=\"crayon-sy\">)<\/span><span class=\"crayon-sy\">;<\/span><\/div>\n<div id=\"crayon-5a30cf5580a45153026120-4\" class=\"crayon-line crayon-striped-line\"><span class=\"crayon-e\">define<\/span><span class=\"crayon-sy\">(<\/span><span class=\"crayon-s\">&#8216;CDN&#8217;<\/span><span class=\"crayon-sy\">,<\/span> <span class=\"crayon-e\">Configure::<\/span><span class=\"crayon-e\">read<\/span><span class=\"crayon-sy\">(<\/span><span class=\"crayon-s\">&#8216;CDN.path&#8217;<\/span><span class=\"crayon-sy\">)<\/span><span class=\"crayon-sy\">.<\/span><span class=\"crayon-cn\">VERSION<\/span><span class=\"crayon-sy\">.<\/span><span class=\"crayon-s\">&#8216;\/&#8217;<\/span><span class=\"crayon-sy\">)<\/span><span class=\"crayon-sy\">;<\/span> <span class=\"crayon-c\">\/* the trailing slash is important *\/<\/span><\/div>\n<div id=\"crayon-5a30cf5580a45153026120-5\" class=\"crayon-line\"><span class=\"crayon-sy\">.<\/span><span class=\"crayon-sy\">.<\/span><span class=\"crayon-sy\">.<\/span><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<div><\/div>\n<div id=\"crayon-5a30cf5580a4a651070038\" class=\"crayon-syntax crayon-theme-classic crayon-font-droid-sans-mono crayon-os-pc print-yes notranslate\">\n<div class=\"crayon-toolbar\"><span class=\"crayon-title\">version.less<\/span><\/p>\n<div class=\"crayon-tools\"><span class=\"crayon-language\">LESS<\/span><\/div>\n<\/div>\n<div class=\"crayon-plain-wrap\"><\/div>\n<div class=\"crayon-main\">\n<table class=\"crayon-table\">\n<tbody>\n<tr class=\"crayon-row\">\n<td class=\"crayon-nums \">\n<div class=\"crayon-nums-content\">\n<div class=\"crayon-num\">1<\/div>\n<\/div>\n<\/td>\n<td class=\"crayon-code\">\n<div class=\"crayon-pre\">\n<div id=\"crayon-5a30cf5580a4a651070038-1\" class=\"crayon-line\"><span class=\"crayon-v\">@VERSION<\/span><span class=\"crayon-sy\">:<\/span> <span class=\"crayon-s\">&#8216;1.0.0&#8217;<\/span><span class=\"crayon-sy\">;<\/span><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<div><\/div>\n<div id=\"crayon-5a30cf5580a4f923849497\" class=\"crayon-syntax crayon-theme-classic crayon-font-droid-sans-mono crayon-os-pc print-yes notranslate\">\n<div class=\"crayon-toolbar\"><span class=\"crayon-title\">style.less<\/span><\/p>\n<div class=\"crayon-tools\"><span class=\"crayon-language\">LESS<\/span><\/div>\n<\/div>\n<div class=\"crayon-plain-wrap\"><\/div>\n<div class=\"crayon-main\">\n<table class=\"crayon-table\">\n<tbody>\n<tr class=\"crayon-row\">\n<td class=\"crayon-nums \">\n<div class=\"crayon-nums-content\">\n<div class=\"crayon-num\">1<\/div>\n<div class=\"crayon-num crayon-striped-num\">2<\/div>\n<div class=\"crayon-num\">3<\/div>\n<div class=\"crayon-num crayon-striped-num\">4<\/div>\n<div class=\"crayon-num\">5<\/div>\n<div class=\"crayon-num crayon-striped-num\">6<\/div>\n<div class=\"crayon-num\">7<\/div>\n<div class=\"crayon-num crayon-striped-num\">8<\/div>\n<div class=\"crayon-num\">9<\/div>\n<div class=\"crayon-num crayon-striped-num\">10<\/div>\n<\/div>\n<\/td>\n<td class=\"crayon-code\">\n<div class=\"crayon-pre\">\n<div id=\"crayon-5a30cf5580a4f923849497-1\" class=\"crayon-line\"><span class=\"crayon-n\">@import &#8216;cdn&#8217;;<\/span><\/div>\n<div id=\"crayon-5a30cf5580a4f923849497-2\" class=\"crayon-line crayon-striped-line\"><span class=\"crayon-n\">@import &#8216;version&#8217;;<\/span><\/div>\n<div id=\"crayon-5a30cf5580a4f923849497-3\" class=\"crayon-line\"><span class=\"crayon-v\">@CDNVER<\/span><span class=\"crayon-k \">: &#8216;@<\/span><span class=\"crayon-sy\">{<\/span><span class=\"crayon-i \">CDN<\/span><span class=\"crayon-sy\">}<\/span><span class=\"crayon-k \">@<\/span><span class=\"crayon-sy\">{<\/span><span class=\"crayon-i \">VERSION<\/span><span class=\"crayon-sy\">}<\/span><span class=\"crayon-i \">\/&#8217;<\/span><span class=\"crayon-sy\">;<\/span><\/div>\n<div id=\"crayon-5a30cf5580a4f923849497-4\" class=\"crayon-line crayon-striped-line\"><\/div>\n<div id=\"crayon-5a30cf5580a4f923849497-5\" class=\"crayon-line\"><span class=\"crayon-k \">button <\/span><span class=\"crayon-sy\">{<\/span><\/div>\n<div id=\"crayon-5a30cf5580a4f923849497-6\" class=\"crayon-line crayon-striped-line\"><span class=\"crayon-h\">\u00a0\u00a0\u00a0\u00a0<\/span><span class=\"crayon-k \">background-image: url(&#8216;@<\/span><span class=\"crayon-sy\">{<\/span><span class=\"crayon-i \">CDNVER<\/span><span class=\"crayon-sy\">}<\/span><span class=\"crayon-i \">img\/button.png&#8217;<\/span><span class=\"crayon-sy\">)<\/span><span class=\"crayon-sy\">;<\/span><\/div>\n<div id=\"crayon-5a30cf5580a4f923849497-7\" class=\"crayon-line\"><span class=\"crayon-h\">\u00a0\u00a0\u00a0\u00a0<\/span><span class=\"crayon-k \">&amp;:hover <\/span><span class=\"crayon-sy\">{<\/span><\/div>\n<div id=\"crayon-5a30cf5580a4f923849497-8\" class=\"crayon-line crayon-striped-line\"><span class=\"crayon-h\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span class=\"crayon-k \">background-image: url(&#8216;@<\/span><span class=\"crayon-sy\">{<\/span><span class=\"crayon-i \">CDNVER<\/span><span class=\"crayon-sy\">}<\/span><span class=\"crayon-i \">img\/button_hover.png&#8217;<\/span><span class=\"crayon-sy\">)<\/span><span class=\"crayon-sy\">;<\/span><\/div>\n<div id=\"crayon-5a30cf5580a4f923849497-9\" class=\"crayon-line\"><span class=\"crayon-h\">\u00a0\u00a0\u00a0\u00a0<\/span><span class=\"crayon-sy\">}<\/span><\/div>\n<div id=\"crayon-5a30cf5580a4f923849497-10\" class=\"crayon-line crayon-striped-line\"><span class=\"crayon-sy\">}<\/span><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<div>The above LESS files are a little awkward because now you have two version files to maintain. Hopefully your environment scripts will make this easy for you to manage. If you don\u2019t have any environment scripts, you should consider having something that makes it easy for you to increment the version number \u2013 a script that reads in the current VERSION, increments it, then writes out VERSION and version.less.<\/div>\n<h3>Conclusion<\/h3>\n<div>The key concepts to setup a CDN that is configurable and maintainable are:<\/div>\n<ul>\n<li>Use a global variable to easily access the URL of your CDN<\/li>\n<li>Prefix the URLs of your static resources with the CDN variable<\/li>\n<li>Use configuration files to define the CDN variable<\/li>\n<li>Set your CDN to fetch resources from an origin server<\/li>\n<li>Invalidate your resources by putting them into a versioned directory<\/li>\n<li>Spoof the versioned directory by using a URL Rewrite<\/li>\n<li>Maintain a version number within a config file<\/li>\n<\/ul>\n<div>There\u2019s no doubt you\u2019ll discover ways to improve on these ideas, but they\u2019re a good starting point. A possible improvement to this scheme is to figure out a way to maintain separate versions of resources. For example it\u2019s likely that\u00a0<em>logo.png<\/em>\u00a0won\u2019t change often, but\u00a0<em>style.less<\/em>will. It could be a waste to invalidate\u00a0<em>logo.png<\/em>\u00a0every time you increment the version in order to invalidate\u00a0<em>style.less<\/em>. As it stands now, all your resources are invalidated even if you mean to invalidate just one of them. This might not be ideal, but perhaps simplicity trumps idealism \u2013 that\u2019s for you to decide.<\/div>\n<div><\/div>\n<\/div>\n<div id=\"comments\" class=\"\">\n<div><i>Source:\u00a0<\/i><a href=\"http:\/\/hippocurious.com\/setup-a-cdn-to-speed-up-your-website\/\" target=\"_blank\" rel=\"noopener\"><i>http:\/\/hippocurious.com\/setup-a-cdn-to-speed-up-your-website\/<\/i><\/a><\/div>\n<\/div>\n<\/div>\n<div><\/div>\n<div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>HOW TO SETUP A CDN TO SPEED UP YOUR WEBSITE:: \u00a0 \u00a0 If you\u2019re looking for ways to speed up your website, one of the &hellip; <\/p>\n<div class='heateor_sss_sharing_container heateor_sss_vertical_sharing heateor_sss_bottom_sharing' style='width:44px;left: -10px;top: 120px;-webkit-box-shadow:none;box-shadow:none;' data-heateor-sss-href='https:\/\/www.chandansharma.co.in\/blog\/wp-json\/wp\/v2\/posts\/853'><div class=\"heateor_sss_sharing_ul\"><a aria-label=\"Facebook\" class=\"heateor_sss_facebook\" href=\"https:\/\/www.facebook.com\/sharer\/sharer.php?u=https%3A%2F%2Fwww.chandansharma.co.in%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F853\" title=\"Facebook\" rel=\"nofollow noopener\" target=\"_blank\" style=\"font-size:32px!important;box-shadow:none;display:inline-block;vertical-align:middle\"><span class=\"heateor_sss_svg\" style=\"background-color:#3c589a;width:40px;height:40px;margin:0;display:inline-block;opacity:1;float:left;font-size:32px;box-shadow:none;display:inline-block;font-size:16px;padding:0 4px;vertical-align:middle;background-repeat:repeat;overflow:hidden;padding:0;cursor:pointer;box-sizing:content-box\"><svg style=\"display:block;\" focusable=\"false\" aria-hidden=\"true\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"100%\" height=\"100%\" viewBox=\"-5 -5 42 42\"><path d=\"M17.78 27.5V17.008h3.522l.527-4.09h-4.05v-2.61c0-1.182.33-1.99 2.023-1.99h2.166V4.66c-.375-.05-1.66-.16-3.155-.16-3.123 0-5.26 1.905-5.26 5.405v3.016h-3.53v4.09h3.53V27.5h4.223z\" fill=\"#fff\"><\/path><\/svg><\/span><\/a><a aria-label=\"Twitter\" class=\"heateor_sss_button_twitter\" href=\"http:\/\/twitter.com\/intent\/tweet?text=Logic%20Bytes%20-%20Spread%20Your%20Knowledge&url=https%3A%2F%2Fwww.chandansharma.co.in%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F853\" title=\"Twitter\" rel=\"nofollow noopener\" target=\"_blank\" style=\"font-size:32px!important;box-shadow:none;display:inline-block;vertical-align:middle\"><span class=\"heateor_sss_svg heateor_sss_s__default heateor_sss_s_twitter\" style=\"background-color:#55acee;width:40px;height:40px;margin:0;display:inline-block;opacity:1;float:left;font-size:32px;box-shadow:none;display:inline-block;font-size:16px;padding:0 4px;vertical-align:middle;background-repeat:repeat;overflow:hidden;padding:0;cursor:pointer;box-sizing:content-box\"><svg style=\"display:block;\" focusable=\"false\" aria-hidden=\"true\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"100%\" height=\"100%\" viewBox=\"-4 -4 39 39\"><path d=\"M28 8.557a9.913 9.913 0 0 1-2.828.775 4.93 4.93 0 0 0 2.166-2.725 9.738 9.738 0 0 1-3.13 1.194 4.92 4.92 0 0 0-3.593-1.55 4.924 4.924 0 0 0-4.794 6.049c-4.09-.21-7.72-2.17-10.15-5.15a4.942 4.942 0 0 0-.665 2.477c0 1.71.87 3.214 2.19 4.1a4.968 4.968 0 0 1-2.23-.616v.06c0 2.39 1.7 4.38 3.952 4.83-.414.115-.85.174-1.297.174-.318 0-.626-.03-.928-.086a4.935 4.935 0 0 0 4.6 3.42 9.893 9.893 0 0 1-6.114 2.107c-.398 0-.79-.023-1.175-.068a13.953 13.953 0 0 0 7.55 2.213c9.056 0 14.01-7.507 14.01-14.013 0-.213-.005-.426-.015-.637.96-.695 1.795-1.56 2.455-2.55z\" fill=\"#fff\"><\/path><\/svg><\/span><\/a><a aria-label=\"Linkedin\" class=\"heateor_sss_button_linkedin\" href=\"https:\/\/www.linkedin.com\/sharing\/share-offsite\/?url=https%3A%2F%2Fwww.chandansharma.co.in%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F853\" title=\"Linkedin\" rel=\"nofollow noopener\" target=\"_blank\" style=\"font-size:32px!important;box-shadow:none;display:inline-block;vertical-align:middle\"><span class=\"heateor_sss_svg heateor_sss_s__default heateor_sss_s_linkedin\" style=\"background-color:#0077b5;width:40px;height:40px;margin:0;display:inline-block;opacity:1;float:left;font-size:32px;box-shadow:none;display:inline-block;font-size:16px;padding:0 4px;vertical-align:middle;background-repeat:repeat;overflow:hidden;padding:0;cursor:pointer;box-sizing:content-box\"><svg style=\"display:block;\" focusable=\"false\" aria-hidden=\"true\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 32 32\"><path d=\"M6.227 12.61h4.19v13.48h-4.19V12.61zm2.095-6.7a2.43 2.43 0 0 1 0 4.86c-1.344 0-2.428-1.09-2.428-2.43s1.084-2.43 2.428-2.43m4.72 6.7h4.02v1.84h.058c.56-1.058 1.927-2.176 3.965-2.176 4.238 0 5.02 2.792 5.02 6.42v7.395h-4.183v-6.56c0-1.564-.03-3.574-2.178-3.574-2.18 0-2.514 1.7-2.514 3.46v6.668h-4.187V12.61z\" fill=\"#fff\"><\/path><\/svg><\/span><\/a><a aria-label=\"Pinterest\" class=\"heateor_sss_button_pinterest\" href=\"https:\/\/www.chandansharma.co.in\/blog\/wp-json\/wp\/v2\/posts\/853\" onclick=\"event.preventDefault();javascript:void( (function() {var e=document.createElement('script' );e.setAttribute('type','text\/javascript' );e.setAttribute('charset','UTF-8' );e.setAttribute('src','\/\/assets.pinterest.com\/js\/pinmarklet.js?r='+Math.random()*99999999);document.body.appendChild(e)})());\" title=\"Pinterest\" rel=\"nofollow noopener\" style=\"font-size:32px!important;box-shadow:none;display:inline-block;vertical-align:middle\"><span class=\"heateor_sss_svg heateor_sss_s__default heateor_sss_s_pinterest\" style=\"background-color:#cc2329;width:40px;height:40px;margin:0;display:inline-block;opacity:1;float:left;font-size:32px;box-shadow:none;display:inline-block;font-size:16px;padding:0 4px;vertical-align:middle;background-repeat:repeat;overflow:hidden;padding:0;cursor:pointer;box-sizing:content-box\"><svg style=\"display:block;\" focusable=\"false\" aria-hidden=\"true\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"100%\" height=\"100%\" viewBox=\"-2 -2 35 35\"><path fill=\"#fff\" d=\"M16.539 4.5c-6.277 0-9.442 4.5-9.442 8.253 0 2.272.86 4.293 2.705 5.046.303.125.574.005.662-.33.061-.231.205-.816.27-1.06.088-.331.053-.447-.191-.736-.532-.627-.873-1.439-.873-2.591 0-3.338 2.498-6.327 6.505-6.327 3.548 0 5.497 2.168 5.497 5.062 0 3.81-1.686 7.025-4.188 7.025-1.382 0-2.416-1.142-2.085-2.545.397-1.674 1.166-3.48 1.166-4.689 0-1.081-.581-1.983-1.782-1.983-1.413 0-2.548 1.462-2.548 3.419 0 1.247.421 2.091.421 2.091l-1.699 7.199c-.505 2.137-.076 4.755-.039 5.019.021.158.223.196.314.077.13-.17 1.813-2.247 2.384-4.324.162-.587.929-3.631.929-3.631.46.876 1.801 1.646 3.227 1.646 4.247 0 7.128-3.871 7.128-9.053.003-3.918-3.317-7.568-8.361-7.568z\"\/><\/svg><\/span><\/a><a aria-label=\"Whatsapp\" class=\"heateor_sss_whatsapp\" href=\"https:\/\/api.whatsapp.com\/send?text=Logic%20Bytes%20-%20Spread%20Your%20Knowledge https%3A%2F%2Fwww.chandansharma.co.in%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F853\" title=\"Whatsapp\" rel=\"nofollow noopener\" target=\"_blank\" style=\"font-size:32px!important;box-shadow:none;display:inline-block;vertical-align:middle\"><span class=\"heateor_sss_svg\" style=\"background-color:#55eb4c;width:40px;height:40px;margin:0;display:inline-block;opacity:1;float:left;font-size:32px;box-shadow:none;display:inline-block;font-size:16px;padding:0 4px;vertical-align:middle;background-repeat:repeat;overflow:hidden;padding:0;cursor:pointer;box-sizing:content-box\"><svg style=\"display:block;\" focusable=\"false\" aria-hidden=\"true\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"100%\" height=\"100%\" viewBox=\"-6 -5 40 40\"><path class=\"heateor_sss_svg_stroke heateor_sss_no_fill\" stroke=\"#fff\" stroke-width=\"2\" fill=\"none\" d=\"M 11.579798566743314 24.396926207859085 A 10 10 0 1 0 6.808479557110079 20.73576436351046\"><\/path><path d=\"M 7 19 l -1 6 l 6 -1\" class=\"heateor_sss_no_fill heateor_sss_svg_stroke\" stroke=\"#fff\" stroke-width=\"2\" fill=\"none\"><\/path><path d=\"M 10 10 q -1 8 8 11 c 5 -1 0 -6 -1 -3 q -4 -3 -5 -5 c 4 -2 -1 -5 -1 -4\" fill=\"#fff\"><\/path><\/svg><\/span><\/a><\/div><div class=\"heateorSssClear\"><\/div><\/div>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[10,9],"tags":[730,731,732,733],"jetpack_publicize_connections":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>HOW TO SETUP A CDN TO SPEED UP YOUR WEBSITE - Logic Bytes<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.chandansharma.co.in\/blog\/how-to-setup-a-cdn-to-speed-up-your-website\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"HOW TO SETUP A CDN TO SPEED UP YOUR WEBSITE - Logic Bytes\" \/>\n<meta property=\"og:description\" content=\"HOW TO SETUP A CDN TO SPEED UP YOUR WEBSITE:: \u00a0 \u00a0 If you\u2019re looking for ways to speed up your website, one of the &hellip;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.chandansharma.co.in\/blog\/how-to-setup-a-cdn-to-speed-up-your-website\/\" \/>\n<meta property=\"og:site_name\" content=\"Logic Bytes\" \/>\n<meta property=\"article:published_time\" content=\"2017-12-15T05:51:56+00:00\" \/>\n<meta name=\"author\" content=\"Chandan Sharma\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Chandan Sharma\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.chandansharma.co.in\/blog\/how-to-setup-a-cdn-to-speed-up-your-website\/\",\"url\":\"https:\/\/www.chandansharma.co.in\/blog\/how-to-setup-a-cdn-to-speed-up-your-website\/\",\"name\":\"HOW TO SETUP A CDN TO SPEED UP YOUR WEBSITE - Logic Bytes\",\"isPartOf\":{\"@id\":\"https:\/\/www.chandansharma.co.in\/blog\/#website\"},\"datePublished\":\"2017-12-15T05:51:56+00:00\",\"dateModified\":\"2017-12-15T05:51:56+00:00\",\"author\":{\"@id\":\"https:\/\/www.chandansharma.co.in\/blog\/#\/schema\/person\/0c7e3da957c6e1375f6b4c899d491b49\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.chandansharma.co.in\/blog\/how-to-setup-a-cdn-to-speed-up-your-website\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.chandansharma.co.in\/blog\/how-to-setup-a-cdn-to-speed-up-your-website\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.chandansharma.co.in\/blog\/how-to-setup-a-cdn-to-speed-up-your-website\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.chandansharma.co.in\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"HOW TO SETUP A CDN TO SPEED UP YOUR WEBSITE\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.chandansharma.co.in\/blog\/#website\",\"url\":\"https:\/\/www.chandansharma.co.in\/blog\/\",\"name\":\"Logic Bytes\",\"description\":\"Spread Your Knowledge\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.chandansharma.co.in\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.chandansharma.co.in\/blog\/#\/schema\/person\/0c7e3da957c6e1375f6b4c899d491b49\",\"name\":\"Chandan Sharma\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.chandansharma.co.in\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/42af2b8ad482f08d8902257fec963abc?s=96&d=identicon&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/42af2b8ad482f08d8902257fec963abc?s=96&d=identicon&r=g\",\"caption\":\"Chandan Sharma\"},\"url\":\"https:\/\/www.chandansharma.co.in\/blog\/author\/chandan\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"HOW TO SETUP A CDN TO SPEED UP YOUR WEBSITE - Logic Bytes","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.chandansharma.co.in\/blog\/how-to-setup-a-cdn-to-speed-up-your-website\/","og_locale":"en_US","og_type":"article","og_title":"HOW TO SETUP A CDN TO SPEED UP YOUR WEBSITE - Logic Bytes","og_description":"HOW TO SETUP A CDN TO SPEED UP YOUR WEBSITE:: \u00a0 \u00a0 If you\u2019re looking for ways to speed up your website, one of the &hellip;","og_url":"https:\/\/www.chandansharma.co.in\/blog\/how-to-setup-a-cdn-to-speed-up-your-website\/","og_site_name":"Logic Bytes","article_published_time":"2017-12-15T05:51:56+00:00","author":"Chandan Sharma","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Chandan Sharma","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.chandansharma.co.in\/blog\/how-to-setup-a-cdn-to-speed-up-your-website\/","url":"https:\/\/www.chandansharma.co.in\/blog\/how-to-setup-a-cdn-to-speed-up-your-website\/","name":"HOW TO SETUP A CDN TO SPEED UP YOUR WEBSITE - Logic Bytes","isPartOf":{"@id":"https:\/\/www.chandansharma.co.in\/blog\/#website"},"datePublished":"2017-12-15T05:51:56+00:00","dateModified":"2017-12-15T05:51:56+00:00","author":{"@id":"https:\/\/www.chandansharma.co.in\/blog\/#\/schema\/person\/0c7e3da957c6e1375f6b4c899d491b49"},"breadcrumb":{"@id":"https:\/\/www.chandansharma.co.in\/blog\/how-to-setup-a-cdn-to-speed-up-your-website\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.chandansharma.co.in\/blog\/how-to-setup-a-cdn-to-speed-up-your-website\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.chandansharma.co.in\/blog\/how-to-setup-a-cdn-to-speed-up-your-website\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.chandansharma.co.in\/blog\/"},{"@type":"ListItem","position":2,"name":"HOW TO SETUP A CDN TO SPEED UP YOUR WEBSITE"}]},{"@type":"WebSite","@id":"https:\/\/www.chandansharma.co.in\/blog\/#website","url":"https:\/\/www.chandansharma.co.in\/blog\/","name":"Logic Bytes","description":"Spread Your Knowledge","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.chandansharma.co.in\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.chandansharma.co.in\/blog\/#\/schema\/person\/0c7e3da957c6e1375f6b4c899d491b49","name":"Chandan Sharma","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.chandansharma.co.in\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/42af2b8ad482f08d8902257fec963abc?s=96&d=identicon&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/42af2b8ad482f08d8902257fec963abc?s=96&d=identicon&r=g","caption":"Chandan Sharma"},"url":"https:\/\/www.chandansharma.co.in\/blog\/author\/chandan\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pajmea-dL","_links":{"self":[{"href":"https:\/\/www.chandansharma.co.in\/blog\/wp-json\/wp\/v2\/posts\/853"}],"collection":[{"href":"https:\/\/www.chandansharma.co.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.chandansharma.co.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.chandansharma.co.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.chandansharma.co.in\/blog\/wp-json\/wp\/v2\/comments?post=853"}],"version-history":[{"count":0,"href":"https:\/\/www.chandansharma.co.in\/blog\/wp-json\/wp\/v2\/posts\/853\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.chandansharma.co.in\/blog\/wp-json\/wp\/v2\/media?parent=853"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.chandansharma.co.in\/blog\/wp-json\/wp\/v2\/categories?post=853"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.chandansharma.co.in\/blog\/wp-json\/wp\/v2\/tags?post=853"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}