Can CF Image variants be pre-generated prior to an initial browser request?
I’m a developer who has implemented CF Images into an e-commerce website. I understand that in order for me to serve any image I have uploaded, each image URL needs to specify a variant, such as /public. However, after uploading a brand new image, it takes a very long while for the image to be viewed in a browser for the very first time. I'm guessing it's because the variant of that image needs to be created first. Then afterwards, it is much faster, across all browsers and computers.
My question is if there is any way to pre-generate the variant of a particular image so that it doesn’t have to be created on-the-fly on an initial browser request?
Or maybe I'm completely misunderstanding how variants work?
2 Replies
My understanding of variants is they're just presets for image optimization, they're all on the fly and cached just like normal Image Resizing.
How long is a "very long while"? I upload a ~16mb image via the dashboard and all the variants are instantly there. You could always send a request for that variant to get it cached on upload before they access it
Thanks for the reply. When you mention that they are cached, do you mean cached on Cloudflare's servers, right? Like an edge cache? And if so, are you aware of any way to set or update the cache policy?