All diagrams
Flow 03 — Channel Stats

The Cache

Channel Stats is a public page: anyone can open it, reload it, or link it somewhere busy. If every visit called the API, one quiet afternoon could burn the whole day's quota.

So the numbers are read once and kept in memory for thirty minutes. Almost every visit is served without leaving the server at all.

azuretestproject.com/channel

A visitor opens the page. No sign-in, no account — anyone at all.

GET /channel

In-memory cache check

One dictionary in the running process, holding the last answer and the moment it was fetched.

Hit · 0 units Younger than 30 minutes → return it straight to the visitor. The request never leaves the server.
Miss Empty or older than 30 minutes → go and ask YouTube, once.

Only on
a miss

At most
once / 30 min

channels.list(mine=True)

1 unit

Read with the owner's stored credentials — the same token the update cycle uses, counted against the same daily budget. Subscribers, total views and video count come back in one response.

Store for
30 minutes

Cached — CHANNEL_CACHE_TTL

~48 units / day

Thirty minutes of TTL means at most 48 reads in a day — whether the page gets ten visitors or ten thousand. The cost of this page does not grow with its traffic.

Refresh failed The stale cached numbers are served anyway. A slightly old scoreboard beats a broken page.
Nothing cached Only then does the page show “Scoreboard offline”.
Server

One read serves every visitor Traffic goes up; the quota bill stays flat.