Common misconception - CDNs can only cache images and videos.
To be honest, CDNs do not care what they get from the origin servers. For them, it is just a stream of bytes 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.)
Like always, whenever we cache things, we always work with this assumption that you are okay serving stale data to users; this holds if you choose to cache API responses as well.
Strong opinions usually have exceptions; dig deeper.