How to reduce loading time of r3f api? #784
-
I am looking for the ways to reduce the loading time of my r3f page (game). I have now in my mind may be two options :
Is there a way to see what’s going in web cache ? If i use the debug tool from chrome i can see differences between using or not webcache, but i don’t really know how to understand theses numbers… Thank you again for your help ! |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 3 replies
-
it's using browser cache anyway. for textures three executes a regular fetch request. you can preload textures in v5, look into the release notes. but most likely your textures are too large. 160mb for a website is crazy. also compress your gltfs with gltf-pipeline and dracos highest compressionlevel. |
Beta Was this translation helpful? Give feedback.
-
You should serve your assets/textures over a cdn where you can set the appropriate cache-control header. This does not happen by default for chrome/firefox and will significantly reduce loading times on subsequent visits. Considering your website is a game, it is expected to have repeat visitors. |
Beta Was this translation helpful? Give feedback.
-
Thank you for yours answers !! @drcmda So i see that i could use useLoader.preload(GTLFLoader, url of the cdn) to preload texture before entering the game. I don't know if i can use jpg texure instead of png for matcaps... For .glb files, is it better to save buffers/textures as embedded or separate files? Probably separate file because i import them with r3f ? @stephencorwin , when you say "This does not happen by default for chrome/firefox", what are you talking about ? Web Cache ? I have to find a way to display video content with low size and maybe only when visitors ask . Thank you !! |
Beta Was this translation helpful? Give feedback.
-
@Franckapik what I mean is just that browsers don't work that way by default. They don't automatically determine to cache and never download a resource again. They must be informed via a header such as This has nothing really to do with react-three-fiber and more to do with just the nature of the web. It's a good thing really. If browsers decided to cache by default, then you could go weeks without seeing updates to sites you visit. This would be especially problematic if one of those updates fixed broken behavior. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
In my game, I actually have
288 MB
being loaded, but it loads almost instantly on subsequent visits due to proper caching.Notice how only
567 Bytes
are actually being transferred. Also notice that the size is marked as(disk cache)
instead of a number.If I click on one, you can see the value of the
Cache-Control
response header from the server.