# How to disable the disk cache when loading image from file

**URL:** <https://discourse.threejs.org/t/how-to-disable-the-disk-cache-when-loading-image-from-file/33214>\
**Category:** Questions\
**Tags:** loaders\
**Created:** [January 2, 2022, 2:30am UTC](https://discourse.threejs.org/t/how-to-disable-the-disk-cache-when-loading-image-from-file/33214 "2022-01-02T02:30:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Avner\_Moshkovitz](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/avner_moshkovitz/32/5297_2.png) [@Avner\_Moshkovitz](https://discourse.threejs.org/u/Avner_Moshkovitz)\
**Post date:** [January 2, 2022, 2:30am UTC](https://discourse.threejs.org/t/how-to-disable-the-disk-cache-when-loading-image-from-file/33214/1 "2022-01-02T02:30:58Z")

</div>

I want to disable disk cache when loading textures from list of files (the loaded files cycle over the list).

I tried to:

- disable THREE.Cache  
`THREE.Cache.enabled = false;`

- set the requestHeader to no-cache

```javascript
const texLoader=new THREE.TextureLoader();
texLoader.requestHeader = { 'Cache-Control': 'no-cache, no-store, must-revalidate' };

```

- set the main html page to no cache  
`<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />`

But I’m still seeing disk cache, in Chrome’s Network tab…

How do I do it?  
Thanks

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/9/f/9fd47c37967e13062a5a7023e5699dc7a5384ad7.png)

---

<div class="post-metadata">

**Author:** ![Avner\_Moshkovitz](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/avner_moshkovitz/32/5297_2.png) [@Avner\_Moshkovitz](https://discourse.threejs.org/u/Avner_Moshkovitz)\
**Post date:** [January 2, 2022, 2:47am UTC](https://discourse.threejs.org/t/how-to-disable-the-disk-cache-when-loading-image-from-file/33214/2 "2022-01-02T02:47:16Z")

</div>

I ended up adding a dummy variable to the request. For example:

```javascript
imgUrl: example2/data/IMG_20190429_083739.jpg?12
imgUrl: example2/data/IMG_20190429_083739.jpg?13

```

The other option is to tick the “disable cache” in Chrome or Safari Network tab.

With that, I’m not seeing the “disk cache” in the “Size” column anymore anymore.

---

<div class="post-metadata">

**Author:** ![donmccurdy](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/donmccurdy/32/33209_2.png) [@donmccurdy](https://discourse.threejs.org/u/donmccurdy)\
**Post date:** [January 3, 2022, 5:05am UTC](https://discourse.threejs.org/t/how-to-disable-the-disk-cache-when-loading-image-from-file/33214/3 "2022-01-03T05:05:25Z")

</div>

`THREE.Cache` affects whether three.js itself will cache the results of requests. `<meta http-equiv="Cache-Control"` is [best avoided](https://stackoverflow.com/a/1341133/1314762).

The behavior you’re seeing is the _browser_ (not three.js) caching requests. You can disable that either with different URL parameters (as you’re doing above) or by changing the settings of the server hosting those files.

---

<div class="post-metadata">

**Author:** ![Chaser\_Code](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/chaser_code/32/20199_2.png) [@Chaser\_Code](https://discourse.threejs.org/u/Chaser_Code)\
**Post date:** [January 3, 2022, 7:02am UTC](https://discourse.threejs.org/t/how-to-disable-the-disk-cache-when-loading-image-from-file/33214/4 "2022-01-03T07:02:26Z")

</div>

Via PHP for one file:  
`<?php echo 'imgUrl: example2/data/IMG_20190429_083739.jpg?v='.time(); ?>`

---

<div class="post-metadata">

**Author:** ![iefreer](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/iefreer/32/28788_2.png) [@iefreer](https://discourse.threejs.org/u/iefreer)\
**Post date:** [February 18, 2024, 9:27am UTC](https://discourse.threejs.org/t/how-to-disable-the-disk-cache-when-loading-image-from-file/33214/5 "2024-02-18T09:27:23Z")

</div>

you should probably overwrite fileloader, set cache option to no-store for the fetch request. another way is to change web server response header to disable cache.
