0

So I am making a carousel with images that come a from source like this one http://lorempixel.com/214/317/?t=1

Everytime you make request to this endpoint a different image shows, but I dont understand why when the img with a source like the previous one , after it has been mounted , then dismounted, and when its mounted again it makes the request to the exact same URL , I thought it was supposed to cache it and get the image from memory.. How can I cache this image ? is there a way to preload the image without mounting the component that contains it ? thanks

Miguel Giménez
  • 425
  • 4
  • 10
  • 1
    According to a quick test, lorempixel is setting no-cache headers. Also: https://stackoverflow.com/questions/42615556/how-to-preload-images-in-react-js –  Mar 20 '18 at 07:17
  • ok thanks! yeah had read that post, but didnt help, so you think that the best way to "cache" the images would be to mount them without displaying them and changing that property if you want to show the image? because its not possible to change those headers right ? – Miguel Giménez Mar 20 '18 at 08:17
  • 1
    Here's one way, using your own image component: https://codesandbox.io/s/zrzk190p5m –  Mar 20 '18 at 08:53

0 Answers0