Client Hints? How best to use them with Caddy?

Has anyone considered implementing client hints in Caddy? Leaner Responsive Images With Client Hints — Smashing Magazine

Would this require a plugin? Is this something you could configure yourself with some JSON/Caddyfile voodoo? Or is Caddy poorly suited for using Client Hints?

Basically I’ve been researching how to serve responsive images.

I successfully followed the instructions at Automatically serve webp if browser supports it resulting in this Caddyfile to get Caddy v1 rewriting jpegs/pngs to webp (still need to figure out how to convert that Caddyfile to v2, but shouldn’t be too hard).

More complex stuff, such as supporting multiple image formats like jpeg2000, appears to require using the picture element in HTML, since it seems it’s not possible to have multiple rewrites in Caddy v1? (What about v2?) But I hate having to write out all of this markup, it would be nice to do it server side. So I’d like to use Client Hints somehow, please!

Browser support isn’t looking too great Can I use... Support tables for HTML5, CSS3, etc

I think if anything, this’ll need to be a plugin. I don’t think Caddy should support features like this by default, there just isn’t wide enough support yet.

1 Like

You might be able to get ~50-90% of the way there with request matchers in v2.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.