I have a div element with multiple background-image but in different positions [0..n].
The images format is png but animated (apng).
At the start, every position has no pictures in there (backgroundImage: none, none, ..., none). However, everytime i update this property with an animated sprite at a certain position, the cache keeps all the previous images referenced in the property and the memory keeps increasing.
function test() {
let charImg = ''
for (let i=0; i<g.characterList.image.length; i++) {
if (charImg !== '') charImg += ', '
let param = '#date=' + new Date().getTime()
charImg += 'url("./sprite.png' + param + '")'
}
const character = document.getElementById('character')
character.style.backgroundImage = charImg
}
In this example i call test() with a simple onclick event. Every call makes the memory increases without being cleared by the garbage collector.
I even tried to remove the div element from dom and create a new one with the new background-image property with the same result.
I even added the following into my html :
<meta http-equiv='cache-control' content='no-cache, no-store, max-age=0, must-revalidate'>
<meta http-equiv='expires' content='0'>
<meta http-equiv='pragma' content='no-cache'>
For information, i need the parameter into the url so the sprite reloads everytime i set the background-image property.
Is there a solution or an alternative to this hellish problem? Thanks in advance.