Need to optimize bandwidth usage by preventing repeated loading of images #118
-
I would like to start by thanking you for such a good library, this is by far the best one i tested. My concern is this; I have noticed that when i open the lightbox and slide among the images it will always load the image as if it was the first time it was seen, by default it is set to infinity, thus if user will maintain pressing 'right' keyboard arrow, he will consume infinite bandwidth, one way to help with this is to disable infinite navigation, but this doesn't solve the whole issue, if for example you have 6 images, the thumbnail slider will show 3 loaded images, if you go to the extreme right, it will show the 3 remaining images loaded, but if you decide to go back to the complete left, it will load again the 3 images on the left. Is there a way to stop loading the same images each time they get removed, this will help tremendously, especially in nextjs apps hosted in vercel where bandwidth is very limited and precious. Thanks once again for this amazing project, it only needs more documentations regarding the advanced api stuff to become #1. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
This shouldn't be an actual issue as long as you serve your images with appropriate For example, if you open one of the demos from the documentation website and swipe through all of the slides you should see that the browser starts serving images from the disk cache. Also, make sure you do not disable the cache in the dev tools. |
Beta Was this translation helpful? Give feedback.
-
Thanks for your answer, the 'disable cache' was checked and i did not notice it, unchecking it indeed solved the problem like you said. |
Beta Was this translation helpful? Give feedback.
This shouldn't be an actual issue as long as you serve your images with appropriate
Cache-Control
headers. Modern browsers cache recently downloaded images, so any subsequent image request for previously downloaded image should be served from local cache.For example, if you open one of the demos from the documentation website and swipe through all of the slides you should see that the browser starts serving images from the disk cache.
Also, make sure you do not disable the cache in the dev tools.