Some APIs are only available in production, and not in the playground. The playgrounds are the Workers instances which power cloudflareworkers.com and the Workers editor UI on dash.cloudflare.com. They do not currently provide Cloudflare features other than Workers.
Some APIs are only available inside a request context. A request context is active during a "fetch" event callback, and, if you pass a Response promise to FetchEvent.respondWith(), any asynchronous tasks which run before the Response promise has settled. Any attempt to use such APIs during script startup will throw an exception.
1 applies to the Cache API
2 applies to:
Timers on the Web Global APIs (set/clear interval/timeout)
From old docs:
1 applies to the Cache API 2 applies to: