If the HTTP cf-cache-status header contains the value DYNAMIC, it means the cache for that particular file isn’t set and is actually bypassed.
It would be cached if it would contain the value HIT.
Furthermore, you’d have to combine AND case with “hostname” containssub.example.com or vice-versa.
Furthermore, make sure that on the origin itself you’re setting the cache response headers, otherwise add them at Cloudflare and make sure Cloudflare reads and respects them accordingly.
Or, combine two rules (or just one).
That way, you tell the Cloudflare what to cache or not.
Otherway would be to use Transform Rules to make sure that cache HTTP headers cache-control contains value like cache-control: max-age=0, no-cache, no-store, must-revalidate.
For example - apply and don’t cache all under /img/ /css/ and /js/ path for main (naked) domain example.com, however (hopefully the correct cache HTTP headers are set and/or sent) cache them for abc.example.com, sub.example.com, www.example.com, etc.:
I am trying to make everything on domain com not to be cached and only domain com /img, /css, /js to be cached. I also want cdn domain com to be cached as well. How may I do that?