We built an internet radio streamer utilizing an icecast server streaming MP3 to Firefox via html5 audio tag. However, sometimes the streamer will stop for whatever reason (disconnection, etc) and when you restart the streamer, it begins streaming from the beginning of the session, which leads us to believe that its playing what is in the browser cache.
The only way to get streamer to play the actual live stream is to delete the history in Firefox. This doesn't happen in other browsers. This also happens if using the flash fallback instead of the html5 audio tag.
Thought about using the following script but didn't think it would apply to this scenario.
<meta http-equiv="Cache-control" content="no-cache" />
Any insight would be helpful. Thanks.
Note: See @MosheL's answer for a modern solution.
Old Answer (and probably still needed for SHOUTcast):
I've found that with SHOUTcast/Icecast streams, the only way to guarantee that you won't be playing from cache is to use the old method of adding a cache-busting URL parameter.
If your original stream URL is this:
http://1.2.3.4/someMountPoint
Then use JavaScript to generate a URL like this when playing:
http://1.2.3.4/someMountPoint?nocache=123456789
This ensures that caching will not happen, as to the browser, they are different resources.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With