Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

160
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!