I’ve noticed that TextureLoader seems to have a different loading process for loading images.
I’ve used an image as a texture and used the same image on an image element in the same page. I noticed that Chrome sent 1 request for each instance even though they are both the same image. Shouldn’t it be already cached once loaded by any of the requests?
You can see that the path of the request is different (small, medium etc.), only the image name is the same. So for Chrome - these are different images.
You should either unify these paths (they may also be generated by three as an asset directory, it’s not easy to tell without seeing how you set it up.), or cache requests manually using a custom proxy.
Could you share what’s in viewer.controller.ts:133 (initiator for the repeated request) ? If it was three, it would show same initiator as the first request.
It calls a service that loops and calls TextureLoader’s load method.
This still doesn’t answer my question. If THREE already requested the resource, why would the browser still request the same resource if I use it on an image tag upon inserting in my DOM?
We can only guess without seeing the code why Chrome ignores the cache. It’s probably the easiest to check in dev tools under Network -> Img. Find the file request and see the cache headers:
If it’s a local server it may disable cache altogether, since its useless during development. It may also happen that you are sending the second request when the first one isn’t finished yet.