Hello. I’m not sure how to configure my Cloudflare protected website to serve content faster. My application is built based on NodeJS and it’s http server can only handle around 600 req/s which is great for usual traffic but not suitable to handle holiday spikes and DDoS. So I had an idea of adding
s-maxage to hold a tiny value and additionally cover it with
stale-while-revalidate x5 of original
s-maxage value, i.e.
s-maxage=2, stale-while-revalidate=10. This way during high traffic periods Cloudflare would be serving my html pages and offload the origin http server. And in case of DDoS attack page would be cached for 2 seconds on Cloudflare, and then only single request will be sent by Cloudflare to origin http server to revalidate html content. So I added the
Cloudflare-CDN-Cache-Control header to all of my html pages but that didn’t work. So I’ve looked over docs and community answers and turns out I need a page rule “Cache Everything” for that so I have a few questions:
- Does enabling “Cache Everything” rule will cache everything that is being requested from my http server immediately? And for how long if so?
- Do I still need
Cloudflare-CDN-Cache-Controlor “Cache Everything” will not work without this header?
- If the answer for the question above is yes then what if I need to avoid caching
/api/*responses? Do I need to create another page rule or setting
Cloudflare-CDN-Cache-Control: s-maxage=0, no-cache, no-store, must-revalidatewould be sufficient?