DEV Community

Salad Lam
Salad Lam

Posted on

Record of trying Cloudflare CDN

Notice

I wrote this article and was originally published on Qiita on 12 August 2021.


Setup

  1. copy ALL existing entries of your domain from current DNS server to Cloudflare DNS server (Please check carefully if all entries is copied, otherwise services using missing entries will be inaccessable)
  2. on your domain name registrar, set DNS server serving your domain name to Cloudflare DNS server
  3. wait at most 48 hours for DNS servers cache expires, Cloudflare also periodly checks if domain name moves to Cloudflare or not
  4. turn on websites under your domain to use Cloudflare CDN

Default caching behavior

Assume that free plan is joined, and no page rule is setup

  1. only file extension is consider, not "Content-Type" response header
  2. html file will not be cached (file with "htm", "html" or "php" extension), file without extension also will not be cached
  3. here shows file with which extension will be cached
  4. for cached file, "Cache-Control" response header will be rewrite to value of "Browser Cache TTL" setting
  5. file with "Set-Cookie" response header will not be cached, although which is cached file extension
  6. value of "Caching Level" setting is "Standard", it means that the cached content becomes invalid if the query string changes

You can refer "cf-cache-status" response header returned by Cloudflare's edge server to know if the request is cached or not.

Under the default caching behavior, you may observe that there is a noticeable delay between domain name is entered and content starts to display on the browser (html file is not cached by default). Then content rendering is fast due to the help of caching image, javascript and css files of Cloudflare CDN.

Top comments (0)