I have a sound like this:
var sound_obj = document.createElement("audio");
sound_obj.src = "../sounds/clic.mp3";
sound_obj.volume = 0.10;
sound_obj.autoPlay = false;
sound_obj.preLoad = true;
sound_obj.type = 'audio/mpeg';
document.addEventListener("click", function(){
sound_obj.play();
});
Everything is working well on all browsers. But in Chrome I see that every time I click, Chrome is asking for favicon.ico from site. Every time. What I am doing wrong?
GET "https://mysite/favicon.ico".
LATER EDIT
It seems to be related by using a service worker ('fetch'). This is my version:
const VERSION = 10;
const CACHE_NAME = 'mysite-cache-v-' + VERSION;
self.addEventListener('fetch', event => {
// Let the browser do its default thing
// for non-GET requests.
if (event.request.method != 'GET') return;
// Prevent the default, and handle the request ourselves.
event.respondWith(async function() {
// Try to get the response from a cache.
const cache = await caches.open(CACHE_NAME);
const cachedResponse = await cache.match(event.request);
if (cachedResponse) {
// If we found a match in the cache, return it, but also
// update the entry in the cache in the background.
event.waitUntil(cache.add(event.request));
console.log("cache fetch");
return cachedResponse;
}
console.log("fresh fetch "+ event.request.url);
// If we didn't find a match in the cache, use the network.
return fetch(event.request, {credentials: 'same-origin', redirect: 'manual'});
}());
});
In Firefox everything is OK, But in Chrome I see that browser is fetching favicon.ico
at every click. If I bypass service worker in Chrome by using Bypass for network
, everything is working fine. I have no clue what is wrong here.
It seems to be a bug in Chrome. You can find the reference here: https://bugs.chromium.org/p/chromium/issues/detail?id=1069731&q=favicon&can=2
You can see it in action on this Mozilla page: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/audio
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