Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

142
Visualizações
How does the loading of an image with "?random=" attached work?

So, I wanted to avoid the cache to see images I'm uploading to this website I'm working on, which I access through localhost.

I hit a handy solution pretty quick:

Attaching to the end of image's path ?random= and a random number generated by Math.floor(). All this with the help of a script.

The HTML showed in the browser:

<img class="gallery_img" src="./uploads/4.jpg?random=172">

Awesome, it works beautifully.

Now, the thing that has been hard to find is an explanation of why and how this actually works.

I mean, 1) how the browser still finds the image in the server with this new path?

Or asked the other way around, 2) how the server handles this ?random=172 attachment and delivers the image asked before that?

If somebody could point me to the right direction I would be grateful.


Solution:

Have a look on what are query parameters.

And if you are dealing with the problem of avoiding the cache, have a look here:

Disable cache for some images

almost 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

That is not part of the path, that is a query parameter.

And most of the times the server of images does not care about query parameters, at least not a literally random one, maybe it would support a query parameter called width or size and dynamically generate an image of the correct size. But random is most likely simply discarded and the image is served normally.

almost 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda