Notice
I wrote this article and was originally published on Qiita on 12 August 2021.
Setup
- 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)
- on your domain name registrar, set DNS server serving your domain name to Cloudflare DNS server
- wait at most 48 hours for DNS servers cache expires, Cloudflare also periodly checks if domain name moves to Cloudflare or not
- 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
- only file extension is consider, not "Content-Type" response header
- html file will not be cached (file with "htm", "html" or "php" extension), file without extension also will not be cached
- here shows file with which extension will be cached
- for cached file, "Cache-Control" response header will be rewrite to value of "Browser Cache TTL" setting
- file with "Set-Cookie" response header will not be cached, although which is cached file extension
- 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)