Structured Content 2022: Join our conference to explore fresh perspectives on content and digital experiences →

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: Get the most out of your content

Sanity.io is a platform to build websites and applications. It comes with great APIs that let you treat content like data. Give your team exactly what they need to edit and publish their content with the customizable Sanity Studio. Get real-time collaboration out of the box. Sanity.io comes with a hosted datastore for JSON documents, query languages like GROQ and GraphQL, CDNs, on-demand asset transformations, presentation agnostic rich text, plugins, and much more.

Don't compromise on developer experience. Join thousands of developers and trusted companies and power your content with Sanity.io. Free to get started, pay-as-you-go on all plans.