Skip to content

Instantly share code, notes, and snippets.

@ajtatum
Created Jan 15, 2021
Embed
What would you like to do?
ImageKit Client Hints
var imageCdnUrl = Configuration["CDN:Images:CdnUrl"];
app.Use(async (context, next) =>
{
context.Response.Headers.Add("Accept-CH", "viewport-width, width, dpr");
context.Response.Headers.Add("Feature-Policy", $"ch-viewport-width {imageCdnUrl};ch-width {imageCdnUrl};ch-dpr {imageCdnUrl};ch-device-memory {imageCdnUrl};ch-rtt {imageCdnUrl};ch-ect {imageCdnUrl};ch-downlink {imageCdnUrl}");
context.Response.Headers.Add("Permissions-Policy", $"ch-viewport-width {imageCdnUrl};ch-width {imageCdnUrl};ch-dpr {imageCdnUrl};ch-device-memory {imageCdnUrl};ch-rtt {imageCdnUrl};ch-ect {imageCdnUrl};ch-downlink {imageCdnUrl}");
await next();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment