1

I'm utilizing both CloudFlare and MaxCDN for my website; MaxCDN handles images and scripts while CloudFlare handles HTML pages (in terms of CDN). I'm not using a custom subdomain for MaxCDN (i.e. I'm using their URLs instead of my own subdomain).

I'm looking at the headers in Chrome for my website, and it is showing that the CloudFlare cache as a HIT for MaxCDN URLs. Huh? What is going on? How (and why) is CloudFlare caching resources on MaxCDN URLs -- I thought CloudFlare caches resources on your own domain only?

I'm asking because, ideally, I want my caching stack to be CloudFlare -> MaxCDN -> my server. In other words, if CloudFlare has a cached resource, it should serve it; if not, it should send users to MaxCDN (when applicable, such as for images and script). So first I need to understand what is going on.

Screenshot showing what is going on

2

Okay, I figured out what was going on.

Our domain is protected by Cloudflare -- including all static resources. When MaxCDN goes to retrieve the static resources from our domain, it is served the resources by Cloudflare. Instead of just grabbing the static resources, MaxCDN also copies the headers on the static resources. As such, when MaxCDN serves those statis resources, it looks like Cloudflare is caching them but infact Cloudflare is not -- the headers are stale headers.

TLDR; Cloudflare is not caching resources served by MaxCDN, it only looks like Cloudflare is.

  • That's really interesting. Nice work figuring that out! – Tim Jan 10 '16 at 21:48
  • Thanks. I'm surprised MaxCDN doesn't clear the headers. Maybe there is a setting in MaxCDN which lets me override the headers. – user4951834 Jan 10 '16 at 21:57
0

Cloudflare does not cache HTML pages unless you specifically tell it to using page rules, but it does cache images and static resources if they exist on the domain. Cloudflare will only cache things on domains you've added to Cloudflare, so if something is on a maxcdn.com domain then there's no way it can cache it.

I can look at this for you, but you need to share the actual URLs. CDNs are complex and you describing what you think is happening is not sufficient to solve the problem.

The answer seems simple - the domain hfa-azadinetwork.netdna-ssl.com is on CloudFlare. There's no other explanation that makes sense to me. If it's meant to be another CDN perhaps there's a partnership agreement in place. Interestingly I'm hitting the Sydney CF node, not the Auckland cache, which I know is closer to me here in New Zealand. As long as it is cached somewhere you probably don't much care by who, so long as it's fast and reliable, right?

Update - see the actual answer above, MaxCDN copies CF headers.

  • I've set Cloudflare to cache HTML assets; that isn't a problem. I was also under the impression Cloudflare only caches assets on the domain you add to Cloudflare, which is why I'm surprised I am seeing "HIT" for assets served on MaxCDN's domain. Could it be because of canonical links? – user4951834 Jan 10 '16 at 2:29
  • Thanks, Tim. Yeah, I don't care where it is cached as long as it is hitting a cache. It is just odd that it is being cached. Cloudflare support says they only cache what is on our domain. – user4951834 Jan 10 '16 at 7:21
  • Yes, I think the other domain is on Cloudflare, so you didn't add it but whoever runs that CDN may reuse Cloudflare. It is a bit odd, but I can't see any other way it could happen. – Tim Jan 10 '16 at 7:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.