Does loadStrings() load from the Browser cache?

Hello everyone,

this is happening to me:

  1. I’m loading a txt file (only one line) once every 10 seconds with loadStrings()
  2. Works. Loaded it already a hundred times.
  3. Then the txt file on the server has changed.
  4. But loadStrings() is still loading the old version of the file.

5. I open a new browser tab…
6. I open the txt file to check it…
7. My browser (Chrome) still opens the old version…
8. I hit the refresh button, and then the new version appears,

  1. In exactly that moment, p5js loads the new version too.

Which means, loadStrings() is loading the file from the browser cache?
Does someone know how to solve that?

  • You can append some random query parameter to the link after character ?.
  • Let’s say you have a variable FILENAME as parameter for loadStrings().
  • So concatenate it w/ ? plus some random stuff or timestamp. Some examples:

loadStrings(FILENAME + '?' + Date.now(), successCallback);.
loadStrings(FILENAME + '?' + performance.now(), successCallback);.

Wow it actually works!

let s = loadStrings(filename + '?a=' + random(0,1000), successCallback);

Changing the file name is a nice trick.
Thank you very much.