Common misconception - CDNs can only cache images and videos ⚡
To be honest, CDNs do not care what they are getting from the origin servers. For them, it is just a stream of bytes that they can cache on edge servers for some time.
Because it is a transparent cache that sits between the user and the origin, you can use it to cache images, videos, JS bundles, and even API responses where the response is not supposed to change often, for example
- Popular searches (semi-personalized)
- Trending topics (semi-personalized)
- Feed for specific cohorts of users (Hotstar, Prime, Netflix, etc.)
We always work with this assumption that if you are caching anything, you should be okay serving stale data to users.
⚡ I keep writing and sharing these engineering nuggets, so if you are keen on learning them, follow along.
youtube.com/c/ArpitBhayani