👀 See Sanity in action: Watch product demo now →

Hey! We're fetching responsive images from <http://cdn.sanity.io|cdn.sanity.io> using `@sanity/image-url` to generate query param transformations. One observation is that...

1 replies
Last updated: Jan 21, 2021
Hey! We're fetching responsive images from cdn.sanity.io using
@sanity/image-url
to generate query param transformations. One observation is that when one or more query param changes value, the request takes quite some time where TTFB is pretty much all of the wait time.• Is anyone else experiencing this?
• Does it just take that long to generate a new version of an image server side maybe?
• Is there something that can be optimized in our transformations query params?
Example image url we have:
https://cdn.sanity.io/images/ &lt;project-id&gt;/&lt;dataset&gt;/&lt;some-img&gt;.png?rect=750,0,1406,1438&amp;w=1112&amp;h=1137&amp;auto=format
After the initial long running request, requests for the same image with the same params are quick.
Jan 21, 2021, 7:30 AM
Hi
user A

Yes indeed, if the image size you are requesting is not cached by the CDN it will take some time to generate the image and send it over to CDN. Therefore we strongly recommend using predefined srcsets with a set of predefined image sizes for various display, and not rely on creating unique images for every viewport width.
Jan 21, 2021, 9:33 AM

Sanity.io – build remarkable experiences at scale

Sanity is a customizable solution that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.