What is CDN and how it fits to Episerver solution (Part 2) – Setup cloudflare

Welcome to the second post of CDN series. In these series, I’m trying to describe how CDN works and with one example show how it can integrate with Episerver and finally we tackle some caching challenges CDN and Episerver has. In this post, we are going to integrate one sample CDN with one of our existing websites. One of  CDN Episerver is using in their managed services called DXC is called cloudflare. I have not affiliated with this company and used it because it may be used by some of DXC clients. Cloudflare is quite good and stable service. They have a very simple dashboard and quite good and fast support. So let’s dig down into it!

  1. I created sample Episerver site and hosted that in http://test5.levo.com.au
  2. Register on cloudflare – It is free (select free-personal plan) (not CC require)
  3. Now you need to provide your domain name(s) – my domain name, in this case, would be levo.com – it may take some time to scan domain

  4. Now you can see list of DNS records which domain scan process fetched. In my case none of them items in the list is relevant, so I removed all of items and add one line for test5:

    Cloudflare proposed me to change my Name Server to use Cloudflare which I haven’t. What I did was just is to remove all items and add my “test5” and associated IP address!

  5. Our original image URL was “http://test5.levo.com.au” so now with our latest cloudflare configuration we can access “test5” using “http://test5.levo.com.au.cdn.cloudflare.net”! So without changing name server, we can test our application. Remember in real world scenario if you need to leverage sage DNS and GEO Loaction DNS, you need to use CDN Domain Name Service!
  6. Next step is to add record to IIS website binding:

  7. And obviously new URL to Episerver:

  8. Navigate to cloudflare URL and you should see CDN version of your site!

Question:

  1. How should  I know the site is using the cache?
    1. In Chome navigate to site using developer tools -> Network
    2. Wait until all site is loaded
    3. Find one of your images comes from Episerver:

    4. You can see “CF-Cache-Status:HIT” in  HTTP Header. That means the image is coming from CDN (more information)
  2. What happens if  I delete my asset file from Episerver?
    1. If you are using CDN URL, CDN will provide the image. That means even if you delete image from your web server, CDN keeps the file till TTL finish (more information)
  3. How should I know HTML is cached or not in CDN?
    1. HTTP Header is where to find out:

    2. As you can see “CF-Cache-Status:HIT” is missing
    3. If you need want to cache HTML as well you can refer here.
  4. If I’m going to use CDN, what about if my image or video (or any asset, even HTML of the site) is live and I need to update it?
    1. This is our next post!

In our next post, we will look into how INVALIDATE CDN cache from Episerver.  We are going to build a NuGet package specifically for cloudflare CDN to invalidate cached content when the content is updated in Episerver. This can improve site performance by caching content as much as possible and allow web editors to publish the latest content ALWAYS and finally we plan for integrating visitor group  with CloudFalre PageRules! This will be amazing journey, next post will come soon 🙂

2 thoughts on “What is CDN and how it fits to Episerver solution (Part 2) – Setup cloudflare

  1. Great post mate!

    1. Thanks my friend 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *