So I was able to make it work by using:
// Cookie prefixes that cause a request to bypass the cache when present.
const BYPASS_COOKIE_PREFIXES = [
"ghost-members-ssr",
"admin-api-session"
];
// URL paths to bypass the cache (each pattern is a regex)
const BYPASS_URL_PATTERNS = [
".*/members/api/member/"
];
Steps to make it work:
Create Worker
- CloudFlare main menu
- Workers
- Create service
- HTTP handler
- use the code from - cf-workers/cache-bypass-on-cookie.js at master · pmeenan/cf-workers · GitHub
Add worker to site:
- Open the site in cloudflare
- Worker routes
- Add route
There is limitation of 100 000 requests per day for worker.
This limit is not enough for sites with high volumes of requests.
Thanks @vikaspotluri123