# Enable Image optimization for image paths
if (req.url.ext ~ "(?i)^(gif|png|jpe?g|webp)$" || req.url.path ~ "^/images/") {
set req.http.x-fastly-imageopto-api = "fastly";
log "This is an image request. Enabling IO";
}
# Stash original URL, because IO parameters will be stripped
# out during vcl_hash and are needed after a restart
if (fastly.ff.visits_this_service == 0 && req.restarts == 0) {
set req.http.x-orig-url = req.url;
}
# Apply failover if appropriate
if (req.restarts > 0 && req.http.io-failover) {
log "Directing request to secondary backend";
set req.url = req.http.x-orig-url;
set req.backend = F_origin_1;
# Re-enable clustering
set req.http.Fastly-Force-Shield = "1";
# Force miss: don't use the cached 404 error, but allow the
# new response to overwrite it
set req.hash_always_miss = true;
}