This page demonstrates the how policy rules can be overriden by parameters specified inline.
table io_policies { "article-main": "crop=660:438&width=660", "article-large": "crop=318:212&width=318", "article-medium": "crop=250:166&width=250", "thumb": "crop=80:53&width=80", "avatar": "crop=1:1&width=150", } sub vcl_recv { #FASTLY recv // Return non-image if (req.url.path !~ "(?i)\.(?:jpg|png)$" || req.url.path !~ "/images/") { return(lookup); } // Signal to send to IO set req.http.X-Fastly-Imageopto-Api = "fastly"; // Don't alter the request if we're running at // the shield, it has already been rewritten if (req.http.Fastly-FF) { return (lookup); } // Policies only, but allow other parameters // to override the policy if (req.url.qs ~ "(?:^|&)policy=([^&]+)") { set var.pol = re.group.1; } set req.url = req.url.path "?" req.url.qs "&" table.lookup(io_policies, var.pol); }
//facepug.io/images/a7/pug-sad.jpg?policy=article-main //facepug.io/images/a7/pug-sad.jpg?policy=article-main&crop=1:1 //facepug.io/images/a7/pug-sad.jpg?policy=article-main&width=300