From 6d175835c736ef5b9e23c4da5368af4990a3bd2e Mon Sep 17 00:00:00 2001 From: Jacob Coffee Date: Mon, 30 Sep 2024 13:59:44 -0500 Subject: [PATCH 1/2] feat(infra): do not cache static 404s --- infra/cdn/main.tf | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/infra/cdn/main.tf b/infra/cdn/main.tf index e7aa77108..64d3e8db2 100644 --- a/infra/cdn/main.tf +++ b/infra/cdn/main.tf @@ -129,6 +129,13 @@ resource "fastly_service_vcl" "python_org" { type = "REQUEST" } + condition { + name = "Don't cache 404s for /static" + priority = 10 + statement = "req.url ~ \"^/static/\" && beresp.status == 404" + type = "CACHE" + } + gzip { name = "Default rules" content_types = [ From 926b463fbb4addfc4ceab29d4547a8876918187a Mon Sep 17 00:00:00 2001 From: Jacob Coffee Date: Mon, 30 Sep 2024 14:04:44 -0500 Subject: [PATCH 2/2] feat(infra): apply condition --- infra/cdn/main.tf | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/infra/cdn/main.tf b/infra/cdn/main.tf index 64d3e8db2..059fd8977 100644 --- a/infra/cdn/main.tf +++ b/infra/cdn/main.tf @@ -68,6 +68,14 @@ resource "fastly_service_vcl" "python_org" { ttl = 0 } + cache_setting { + action = "pass" + cache_condition = "Don't cache 404s for /static" + name = "No caching for /static 404s" + stale_ttl = 0 + ttl = 0 + } + condition { name = "Force Pass No-Cache No-Store" priority = 10