From 384dcc9231d6155c285fb0c2c5c8dea93713023c Mon Sep 17 00:00:00 2001 From: Jan David Date: Thu, 9 May 2024 18:38:20 +0300 Subject: [PATCH] Tag rustup artifacts with surrogate key We use surrogate keys[^1] on Fastly to invalidate the cache for specific objects, e.g. when new versions of Rust or rustup are released. Surrogate keys are transparently set in the Fastly configuration based on the request path. A new VCL snippet has been added that tags every rustup artifact with the `rustup` surrogate key so that we can purge them from the cache when a new rustup version is released. --- .../modules/release-distribution/fastly-static.tf | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/terragrunt/modules/release-distribution/fastly-static.tf b/terragrunt/modules/release-distribution/fastly-static.tf index a98f8b34e..c5d4592b0 100644 --- a/terragrunt/modules/release-distribution/fastly-static.tf +++ b/terragrunt/modules/release-distribution/fastly-static.tf @@ -79,6 +79,21 @@ resource "fastly_service_vcl" "static" { VCL } + # When a new version of rustup is released, the release script invalidates + # the CloudFront cache for `/rustup/*` and any object that is tagged with + # the `rustup` key on Fastly. + # See https://github.com/rust-lang/rustup/blob/master/ci/sync-dist.py for + # details. + snippet { + name = "set cache key for rustup" + type = "fetch" + content = <<-VCL + if (req.url ~ "^\/rustup\/") { + set beresp.http.Surrogate-Key = "rustup"; + } + VCL + } + snippet { name = "redirect rustup.sh to rustup.rs" type = "error"