Caching and freshness
What is cached, for how long, how to tell a cache hit, and how to ask for fresh data.
The first request for something does the work. Every later request for the same thing is answered from the cache — for you, and for everyone else. This is the main reason agentic-yt is fast, and the main reason it is gentle on YouTube.
What is cached, and for how long
| What | Kept for | Keyed by |
|---|---|---|
| Video metadata — title, description, chapters, tags | 7 days | video |
| Video counters — views, likes, comment count | 1 hour | video |
| Transcripts | 30 days | video, language, kind |
| Downloads | until evicted | video, kind, format, quality |
| Clips | until evicted | video, kind, format, quality, start–end |
| Frames | until evicted | video, timestamp, format, width |
Files have no expiry date. When space is needed, the least recently used are removed first; a file that keeps being asked for stays.
How to tell
Every cached surface says whether it was a hit:
- Video metadata —
cache.hit, pluscache.stable_fetched_atandcache.counters_fetched_at, so you can see how old each half is. - Transcripts —
cache_hit. - Jobs —
cache_hiton the job (true only if everything was cached) and on each asset.
A job that is a full cache hit comes back succeeded straight from the POST, with HTTP 200. It
is never queued, does not count toward your concurrent jobs, and uses no quota.
What counts as "the same"
Requests are normalised before they are compared, so equivalent requests share a cache entry:
"1:30",90,90.0and"1m30s"are the same time.- An omitted
formatand the defaultformatare the same. quality: "best"andquality: "1080p"are the same, becausebestis capped at 1080p.- A YouTube URL and the bare id it contains are the same video.
- Audio as
wavignoresaudio_bitrate, so every bitrate shares one WAV.
A different quality, format, bitrate, range, timestamp or width is a different file.
Align your requests to hit the cache
If several agents (or several runs of one) work on the same videos, agree on parameters. Everyone
asking for 720p MP4 shares one file; one agent asking for 480p makes a second. The defaults are
the best meeting point — omit what you do not need to control.
Asking for fresh data
Only video metadata has a bypass:
ayt video <ref> --fresh # GET /v1/videos/{id}?fresh=trueIt refetches both halves from YouTube and updates the cache for everyone. Use it when a stale view count would be wrong for the task — not by default, since it is slower and can be refused where the cached answer cannot.
Transcripts and files have no bypass: a published video's captions and streams do not meaningfully change.
Asset URLs expire; assets do not
The url on an asset is signed and stops working at expires_at (up to 7 days after it was
issued). The file is still cached. To get a working URL again, GET the job, or repeat the request
that made it — a cache hit, with a fresh URL.
Do not store asset URLs as permanent links. Store the request (video id plus parameters) or the job id.
Shared and private
The cache is shared across accounts by default. That is safe because a cache entry is identified only by public facts — the video and the output parameters — and holds only what YouTube serves anyone.
The exception is anything fetched using a connected YouTube account.
Those results are stored privately, keyed to the account that owns the cookies, and are never
served to anyone else. If you request a public video with use_account: true, you get a private
copy and do not benefit from, or contribute to, the shared one — a reason to leave use_account
unset unless you need it.
Quota
Cache hits are free. The daily quota counts only requests that had to reach YouTube. A transcript you (or anyone) already fetched, a file that already exists, metadata still inside its freshness window — none of them use quota, and none of them take one of your three job slots.
Every response says which it was in the X-Cache header: hit or miss.