I'm making an audio heavy page. I'm using the JavaScript audio element. The code looks like this:
JavaScript:
var x = new Audio("x.mp3");
var y = new Audio("y.mp3");
var z = new Audio("z.mp3");
function playMe(n){
n.play();
}
HTML:
<button class="button" onclick="playMe(x)")>Play</button>
<button class="button" onclick="playMe(y)")>Play</button>
<button class="button" onclick="playMe(z)")>Play</button>
I'm trying to find a way to save bandwith, and I was suggested that I should use either cache headers in the web server or a cache manifest. Here is the thread:
Is there a way in JavaScript (or any other way) to check the contets of the browser's cache? The goal is to achieve something like this:
if (file in the cache){
use the file in the cache;
}
else{
var x = new Audio("x.mp3");
var y = new Audio("y.mp3");
var z = new Audio("z.mp3");
}
The audio file is downloaded when the Audio object is declared.
Is there a way to do this?