I'm developing an audio captcha system. My problem is that when the audio file containing the numbers which the user must type is updated on the server, the browser doesn't refresh it. Instead, it plays the old, invalid audio until the browser is closed down. How can I make the element rebuffer the audio each time load and play are called instead of playing stored versions? Thanks.
Asked
Active
Viewed 219 times
1
-
2Use a randomizer `?_=
` at the end of the audio file url? – techfoobar Feb 13 '13 at 15:03
1 Answers
2
Browsers generally enjoy caching elements they are sent with exactly the same file name. Normally the best way to avoid this in javascript is to add a function that adds some useless random string to the resource. For example audioNotToBeCached.snd?1421124sjam2
The random string after the question mark is ignored and the browser can't cache based on filenames any more.
Plenty of options here.
-
Thank you- this worked well. I put the current timestamp at the end of the audio url and now the audio stream always matches the current captcha string. Thanks again. – user2059509 Feb 13 '13 at 15:25