How to fix this page rule to cache a html page served via a custom domain?

Hello community!

I am testing Cloudflare for SaaS along with caching and page rules, and I’m hitting a problem - I cannot for the life of me get Cloudflare to cache the pages.

My setup:

  1. I have the custom domain working with SSL with a CNAME pointing to my domain: serve.duckdocs.com
  2. I have the page set up to return a Cache-Control header of max-age=600, public, s-maxage=600
  3. I have the page rule set up to cache anything /pages/ (see below)
  4. I don’t get a cache hit, I get a BYPASS
  5. I have page rules for both example.vamosdata.com/pages/* and serve dot duckdocs dot com/pages/*, which lead to BYPASS and DYNAMIC respectively.

image

  1. At the origin or at Cloudflare? :thinking:
  2. example and serve are both proxied and :orange:

Are you using WordPress APO on your naked domain maybe?

Are you getting BYPASS / DYNAMIC when you open “custom domain” (which loads contents from a CNAME your domain), while for serve and/or duckdocs you get HIT? :thinking:

From the screenshot, I can see it’s the 3rd rule, however what are the 1st and 2nd, which might “overwrite” and execute after the 3rd one, therefore you’d end up having BYPASS because.

Ok, so here’s the setup:

  1. I control duckdocs.com, this is in Cloudflare, and serve.duckdocs.com is proxied
  2. Site is a Ruby on Rails app. No wordpress anywhere
  3. vamosdata.com is a customer domain, I do not control it. They have set a CNAME - example.vamosdata.com => serve.duckdocs.com
  4. I have added example.vamosdata.com as a custom domain in my Cloudflare account, I verified for SSL using HTTP, that worked.
  5. When going to example.vamosdata.com/pages/first-page, SSL works, but the html page itself gives me either BYPASS or dynamic, depending on what page rules I set.

Page rule experiments:

On my server I am setting the Cache-Content header to:
max-age=600, public, s-maxage=600

Screenshot of current page rules:

  • Option 1: */pages/*: Cache Everything - always get BYPASS
  • Option 2: serve.duckdocs.com/pages/* Cache Everything - always get DYNAMIC
  • Option 3: example.vamosdata.com/pages/* Cache Everything - always get BYPASS

What I’d expect:

I’d expect a HIT on any HTML page under example.vamosdata.com/pages/*

Thanks for your help before, do you have any ideas why this does not work with the configuration above?