Static Private cacheStatic Private decodedStatic Private pendingStatic Private pendingGet an AudioBuffer for the specified URL, using intelligent caching strategies.
Caching Flow:
The cache prioritizes HTTP conditional requests (ETag/Last-Modified) over TTL to ensure content freshness while maintaining performance through 304 responses.
AudioContext for decoding audio data
URL of the audio resource to fetch
Optional signal: AbortSignalOptional AbortSignal to cancel the operation
Optional callbacks: CacheCallbacksPromise that resolves to decoded AudioBuffer
Error if audio cannot be fetched or decoded
Static Private callCalls all registered callbacks for a specific event type on a URL.
Generic over the callback name so the payload type is checked against
the canonical CacheCallbacks shape rather than any.
Static Private collectCollects all chunks from a ReadableStream into a single ArrayBuffer
The ReadableStream to collect from
Optional knownLength: numberPromise that resolves to the complete ArrayBuffer
Static Private createCreates a ReadableStream wrapper that tracks download progress.
Uses the callback aggregation system to emit progress to all registered listeners.
Honours signal between reads and releases the underlying reader on
any exit path (done, error, abort).
The fetch Response object with ReadableStream body
URL being downloaded (for progress event data and callback lookup)
Optional signal: AbortSignalOptional AbortSignal observed at chunk boundaries
Object containing the progress-tracking stream and total size
Static Private decodeStatic Private fetchStatic Private getStatic Private getStatic Private getOptional signal: AbortSignalOptional callbacks: Pick<CacheCallbacks, "onLoadingProgress">Static Private openStatic setStatic Private updateStatic Private writeAtomically write a response body and its metadata into the cache.
On failure, deletes both partial entries (best-effort via allSettled)
and rethrows the original error.
AudioCache provides efficient caching of audio resources using HTTP caching standards.
Features:
Caching Strategy:
Example