Cloudflare and Ghost - bypass cookies

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

  1. CloudFlare main menu
  2. Workers
  3. Create service
  4. HTTP handler
  5. use the code from - cf-workers/cache-bypass-on-cookie.js at master · pmeenan/cf-workers · GitHub

Add worker to site:

  1. Open the site in cloudflare
  2. Worker routes
  3. 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

2 Likes