Is there a way to cache audio element requests without Service Workers?

141 Views Asked by At

I have a userscript where I'd like to cache audio files from audio elements. fetch() isn't viable here as I have to wait for it to fetch to get a blob out of it. Is there a way to use the audio element itself for caching? The codec of the audio is FLAC.

1

There are 1 best solutions below

5
Brad On

If you use the appropriate Cache-Control header, the browser will cache for you. No other work is required.

For example:

Cache-Control: public, max-age=604800, immutable