Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

155
Vistas
Is there an official way to avoid cache for some img image elements?

This has been discussed here and there. I'd made my own solution but I'm wondering if there is some modern official solution by newer standard as ECMAScript 2016.

My solution is a hack in the src property adding a random fake property in the end:

function xhrUrlHackNoCache(first) {
    var hack = (first)? "?nocache=" : "&nocache=" ;
    for(let i=0; i<5; i++) {
        hack += Math.floor(Math.random()*10).toString();
    }
    return hack;
}

Personally, I think this is ugly...

There is some interesting discussion here. Some I already tested and won't work as header definition, not even when loading the image trough a php script (maybe if I load the image as 64 and create the img object). Maybe manipulating .htaccess file, but I don't have much knowledge about (sometimes I drop my website messing with this file).

The heaven to me will be some img property set to avoid the cache and load this imagem from the file. Is there something like this? What's the best practice in this case today?

If there is nothing new to add to this issue (that has a lot of duplicates) than I might delete it, no problem, but I think is a good idea to update the knowledge about it.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda