Working with legacy sites
When working with sites hosted by Mr.F / Scalability which are using Cloudflare as a DNS / CDN provider, below are a few gotchas and things to keep in mind.
The server at Mr.F / Scalability will be referred to as “origin server” in this document. Cloudflare will be referred to as “CDN”.
Site is responding slowly / high load experienced on the server
This is probably caused by requests going directly to the origin server instead of through the CDN. You can verify this by going to the site and checkin the server response in the network tab (the first document response in the list).
Look in the response headers of the request. The cf-cache-status
header should have a value of HIT
, MISS
or EXPIRED
which indicates that it is configured to be cached in cloudflare. If the value is BYPASS
or DYNAMIC
, it is NOT configured to be cached in cloudflare. Follow the steps below to make sure everything is cached.
IMPORTANT!
Only do this if you know what you’re doing and know that the site can be cached without adverse effects. For example, if you use next.js middleware functionality, applying CDN cache to all pages will break it.
- Go to Cloudflare admin panel.
- Select your website
- Go to Rules > Page Rules in the sidebar
- Create page rule
- Set URL to www.yoursite.com/_ (or yoursite.com/_ if site don’t use www)
- Set setting to “Cache level” and “Cache everything” (or other appropriate value)
- Save and deploy page rule
- Do the same thing for cms.yoursite.com/wp-json/* (or wherever your wordpress cms is located)