Sorry all, I guess I’m looking for a more specific answer on request lifecycle here of APO requests. Appreciate the help.
The goal is not just general performance improvements, it’s about completely protecting the origin as much as possible by off-loading nearly 100% of requests to Cloudflare. I want to compare Cloudflare’s APO setup versus manual setups with them.
I want my origin to basically be a potato and the site to serve near statically as possible.
This is currently possible a couple ways with Cloudflare if you put the site into the wilderness with them:
Scrape it and deploy as workers site (true static)
Can do but not my goal for this one. Worker Sites store all assets in KV so those requests can be whatever. The real origin can be wherever too (local, remote and hidden, etc…)
- User visits site
- First request loads out of KV as 200
- Second request sent from KV/Worker Cache as 304 until Worker cache TTL expires or cache is cleared
Page Rule to Cache Everything (fake/near static)
From each of Cloudflare’s PoPs, they will hit my origin once until edge TTL expires. My
cf-cache-status-hit. You can improve this with Argo and tiered caching if you really want to (aka, less PoP’s hitting your server). The big con is (unless you are an enterprise plan) you can’t choose to ignore query strings and cache everything (e.g.: /lander?utm=1 and /lander?utm=2 are separate caches).
- => User visits site
- =>First request sent from origin as 200
- =>Second request sent from edge cache as 200 until edge cache TTL expires or cache is cleared
Custom Worker to Cache Everything, Ignore Query Strings (fake/near static)
Just a custom script to throw into cache via worker. Look like anything but might look something like this:
- =>User visits site
- =>First request loads sent from origin as 200 and cached by worker
- =>Second request loads sent from worker cache as 200 until worker cache TTL expires or cache is cleared
Cloudflare APO (fake/near static?)
So what is happening with
.pngs? Directly from Cloudflare APO page:
Automatic Platform Optimization is the result of using the power of Cloudflare Workers to intelligently cache dynamic content. By caching dynamic content, Cloudflare can serve the entire website from our edge network to make a site’s time to first byte (TTFB) both fast and consistent.
So… how often are we loading from origin versus the other options here listed here for non-dynamic content. Let’s pretend the site has no dynamic content and is never going to change. Is it basically:
- => User visits site?
- => First request loads out of origin as 200?
- => Second request loads out of Cloudflare Worker cache as 200 or 304?
- => What about query strings?
- => When does that expire, etc…?
Just trying to understand the lifecycle, thanks! Sorry this got long