Hazard
04/09/2022, 9:10 PMhttps://i.imgur.com/RvBF5NA.png▾
Hazard
04/09/2022, 9:11 PMHazard
04/09/2022, 9:12 PMIsaac McFadyen | YYZ01
04/09/2022, 9:12 PMHazard
04/09/2022, 9:12 PMIsaac McFadyen | YYZ01
04/09/2022, 9:13 PMHazard
04/09/2022, 9:13 PMHazard
04/09/2022, 9:19 PMStew
04/10/2022, 12:13 PMcacheEverything
& `cacheTtl `https://developers.cloudflare.com/workers/runtime-apis/request/#requestinitcfproperties properties to store the results of that request in the cdn, rather than worker cache. (So cache status shows MISS/HIT instead of dynamic)
Pros
Can utilize cdn tiered cache to get more cache hits
Reduced load on external downstream systems (db/external apis)
Save costs if a function has a long runtime
Can invalidate cdn globally using the api, compared to the worker cache where you can only create/delete from the workers cache in the data centre the request is being run in.
Cons
Not worth doing if your page is lightweight
Lose control of cdn/cache duration on function level, this is controlled at the worker level now (eg even if function has cache-control private, it will be cached if the worker sets it to be cached)
The function can't return headers that would store it in cache, as it will go to the workers cache as well. So you need to know before sending the request to the function whether the result should be cached (eg path, presence of a header/cookie etc)
You'll always run a worker for every request, there's no way to have the CDN in front of the worker which could be done if you used an external origin (tradeoff which imo is worth it due to how cheap workers are).
More complicated CORS/host setup.travtrax
04/10/2022, 5:26 PMHazard
04/11/2022, 1:18 AMErwin
04/11/2022, 1:21 AMHazard
04/11/2022, 1:21 AMsimpson
04/11/2022, 10:55 AMSeb
04/11/2022, 3:54 PM{HOST}/favicon.ico
or {BASE_DOMAIN}/public/favicon.ico
or {BASE_DOMAIN}/static/favicon.ico
.
├── functions
│ └── [[path]].ts
└── public
├── favicon.ico
Isaac McFadyen | YYZ01
04/11/2022, 3:54 PMSeb
04/11/2022, 3:55 PMIsaac McFadyen | YYZ01
04/11/2022, 3:55 PMcontext.next()
Isaac McFadyen | YYZ01
04/11/2022, 3:56 PMSeb
04/11/2022, 3:56 PMIsaac McFadyen | YYZ01
04/11/2022, 3:56 PMIsaac McFadyen | YYZ01
04/11/2022, 3:56 PMIsaac McFadyen | YYZ01
04/11/2022, 3:57 PMpublic
if you want to access things in public
Seb
04/11/2022, 4:02 PMSkye
04/11/2022, 4:02 PMPagesFunction
type from @ cloudflare/workers-types in my function, but I'm not sure how to use it correctly? There doesn't appear to be a way to type an entire functionIsaac McFadyen | YYZ01
04/11/2022, 4:03 PMSkye
04/11/2022, 4:03 PMSkye
04/11/2022, 4:04 PMIsaac McFadyen | YYZ01
04/11/2022, 4:04 PM