# Does loadStrings() load from the Browser cache?

**URL:** https://discourse.processing.org/t/does-loadstrings-load-from-the-browser-cache/38700
**Category:** Beginners
**Created:** [September 10, 2022, 6:37am UTC](https://discourse.processing.org/t/does-loadstrings-load-from-the-browser-cache/38700 "2022-09-10T06:37:55Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Jan](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jan/32/2572_2.png) [@Jan](https://discourse.processing.org/u/Jan)
#### Post date: [September 10, 2022, 6:37am UTC](https://discourse.processing.org/t/does-loadstrings-load-from-the-browser-cache/38700/1 "2022-09-10T06:37:55Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)
#### Post date: [September 10, 2022, 9:18am UTC](https://discourse.processing.org/t/does-loadstrings-load-from-the-browser-cache/38700/2 "2022-09-10T09:18:33Z")

</div>

> [@Jan](#):
>
> Which means, **loadStrings()** is loading the file from the browser cache?

- 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);`.

> **[Date.now() - JavaScript | MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now)**
>
> The Date.now() static method returns the number of milliseconds elapsed since the epoch, which is defined as the midnight at the beginning of January 1, 1970, UTC.

> **[Performance: now() method - Web APIs | MDN](https://developer.mozilla.org/en-US/docs/Web/API/Performance/now)**
>
> The performance.now() method returns a high resolution timestamp in milliseconds. It represents the time elapsed since Performance.timeOrigin (the time when navigation has started in window contexts, or the time when the worker is run in Worker and...

---

<div class="post-metadata">

### Author: ![Jan](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jan/32/2572_2.png) [@Jan](https://discourse.processing.org/u/Jan)
#### Post date: [September 12, 2022, 1:25pm UTC](https://discourse.processing.org/t/does-loadstrings-load-from-the-browser-cache/38700/3 "2022-09-12T13:25:37Z")

</div>

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.
