javascript - Cached content for image element kept in browser after being removed and added again -


we developing web app interface uses ajax/javascript entirely.

there dynamic images cache expiration times of access + 15 minutes. so, when images accessed cached 15 minutes , after time browser fetch new version, caching again 15 minutes , on.

the issue in ajax setup, when image elements removed , added, newly added image element (which on 15 minutes later, when browser fetch new image version) not contain new content. i.e. once image loaded in once, after element removed, if element re-added @ other stage without page being changed, loaded version display.

so far issue chrome, i've not tested other browsers yet. image appears sort of held in "memory" when image element removed, image shows under "resources" in chrome developer tools - again, long after image element specifying image source has been removed.

what can this? solution far change image filename on subsequent loads (the old query string trick perhaps). issue here these images stack in "resources" tab of developer tools, though they're being held open, despite image elements being removed.

hope made sense. thoughts? want chrome (and maybe other browsers have issue) load image regardless of source on new image elements. is.. route of check cache, if expired fetch server , cache again.

cheers

the way i've solved append random query string on path of image. example:

<img src="myimage.gif">  

becomes

<img src="myimage.gif?a=randomnumber"> 

the random number force browser grab newest version.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -