Don't cache images that have failed to load
Since I am working with IPFS (decentralized image storing), many images don't load if they haven't been opened recently (cached by IPFS). This means whenever I run a link through Cloudinary image optimizer, the optimizer caches the images even if it failed to load (usually timeout).
```
Ex) This image is sent through my image optimizer link: https://{project-name}.mo.cloudinary.net/{imageURL}. Since this is the first time the image is being called in a while, there is a timeout as IPFS gets the image. Cloudinary then caches the timeout and doesn't show the image for a month. 30 minutes after calling the image, it is now loading with no timeout, but Cloudinary has already cached the 404 response and won't show the image.
```
So, well after the IPFS image has been loaded and is available for view, the Cloudinary image optimizer still has the failed image cached so it doesn't show on my site. Is there a way to make Cloudinary not cache an image if it receives a timeout or any error? This means the next time someone loads the image and it DOES work, then it will cache and display it.
-
Hi there,
Thank you for reaching out.
Currently, it is not possible to not cache links that return an error but I have increased the timeout for your account so please let me know if that helps.
Alternatively, you can invalidate errored links via the UI or API per https://cloudinary.com/documentation/media_optimizer_api#cache_invalidation.
Please do not hesitate to ask me any other questions or queries.
Kind Regards,
Thomas0 -
Thanks Thomas!
The increased timeout helped very slightly, IPFS sometimes takes ~5 minutes to retrieve. Is it possible to max out the timeout length?
Also, this invalidate error link API will probably work. What would be the downsides to invalidating the cache every time the image doesn't load? If it doesn't load for a single user will it invalidate for all?/
Thank you,Quokka
0 -
Hi Quokka,
Thanks for getting back. Unfortunately, the timeout is already max.
And yes the invalidation will invalidate for all users/devices as our edge servers will have to fetch the resource.
Please let me know if you have any other questions or queries.
Kind Regards,
Thomas0
Post is closed for comments.
Comments
3 comments