These instructions assume you have logged into Cloudflare and that you have set up your Domain & DNS records, and are on the Page Rules page.
Get traffic off your naked domain (i.e. yourdomain.com)
Select "Create Page Rule"
Populate the fields with these values:
URL: yourdomain.com/*
Pick a Setting: Forwarding URL | 301 - Permanent Redirect
Enter destination URL: https://www.yourdomain.com/$1 (note we're sending them to HTTPS and $1 passes everything passed in through the wildcard)
Select "Save Page Rule"
Ensure your traffic is on HTTPS & cache all files on your domain
Select "Create Page Rule"
Populate the fields with these values:
URL: www.yourdomain.com/*
Pick a Setting: Cache Level | Cache Everything (This was what I wanted, but you simply pick what is appropriate to you, of course, if you want to cache only files in a certain folder, you will need to set up a new rule to achieve this)
Add a Setting: Always Use HTTPS
Testing your DNS
I've written a small web application that will give you a suite of URLs to test based on a URL for your domain.
Troubleshooting your DNS
At the time this was written, if you chose "Always Use HTTPS", you don't have the option to add another rule, which is why I say to pick your cache level first
If you see an error similar to the below message, when you navigate to your domain, it could be because you've left the wildcard off your URL.
Server encountered an internal error. Please try again after some time.
HttpStatusCode: 500
ErrorCode: InternalError
RequestId : baa3ba74-501e-0092-1ccd-7d4eef000000
TimeStamp : 2022-06-11T19:58:21.6557218Z
Comments