CDN not caching get request

cdn

#1

I’m making get requests that aren’t being cached as expected. Caching works for my javascript bundles (I can see the HIT from my client server) but API requests with a cache header are not. My only thought is that these requests are not being cached because of something to do with the fact that they are proxied through the client server from another on api on a subdomain.

For example, I have an API server at api.domain .com that gets proxied through domain .com/api. On the proxy I remove some headers because of a error 1000 issue: here. The headers I’m removing on the proxy are the following: ‘cf-connecting-ip’, ‘cf-ipcountry’, ‘cf-visitor’, ‘cf-ray’, ‘x-forwarded-for’, ‘x-forwarded-proto’,.

Ideally I’d want the api cached at the api subdomain and more importantly the main domain.

Note, I used to use the vanilla deployment setup from zeit.co (now) and it was being cached as expected (some automatic setting of theirs). It only stopped working after I switched to the cloudfare configuration.


#2

Likely due to this:

Unless you have a “cache everything” page rule, CF will only cache certain file extensions.

No mime checking or anything of the sorts is done, so you very well could make your API endpoints reachable at /endpoint.js to get them cached without any page rules.


closed #3

This topic was automatically closed after 30 days. New replies are no longer allowed.