I am exploring use case of Cloudflare Workers these days. One of useful function is to leverage Cloudflare workers to serve as edge cache to speed up website load time and user experience.
Here are some simple steps to get it setup fast
- Install Cloudflare Page Cache WordPress Plugin
- Go to Cloudflare > Workers
- Click ‘Add Script’
- Give a name
(any name)
- Click ‘Edit’
- Delete all existing code
- Add ‘Route’
Copy codes from https://raw.githubusercontent.com/cloudflare/worker-examples/master/examples/edge-cache-html/edge-cache-html.js
Paste Workers codes
Edit codes with your Cloudflare credentials
email: “”, // From https://dash.cloudflare.com/profile
key: “”, // Global API Key from https://dash.cloudflare.com/profile
zone: “” // “Zone ID” from the API section of the dashboard overview page https://dash.cloudflare.com/ - Add ‘Route’
- Create Route
Refer https://developers.cloudflare.com/workers/about/routes/#matching-behavior for how to write a route.
Click on dropdown and select your script
Click ‘Save’
All Done!
Leave a Reply to felix Cancel