Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions terraform/cache.tf
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add comment(s) to tge relevant part of this file explaining what we've learned about the is-404 codepath?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes will do

Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ resource "fastly_service_vcl" "cache" {
name = local.cache_domain
default_ttl = 86400

# https://registry.terraform.io/providers/fastly/fastly/latest/docs/resources/service_vcl#activation-and-staging
# activate should not be set to true when stage is also set to true. While this combination will not cause any harm to the service,
# there is no logical reason to both stage and activate every set of applied changes.
activate = false # set to true to deploy
stage = true # set to false to remove staging environment

backend {
address = "s3.amazonaws.com"
auto_loadbalance = false
Expand Down Expand Up @@ -174,6 +180,13 @@ resource "fastly_service_vcl" "cache" {
type = "REQUEST"
}

condition {
name = "is-nar"
priority = 10
statement = "beresp.status == 200 && req.url ~ \"^/nar/\" "
type = "CACHE"
}

domain {
name = "cache.nixos.org"
}
Expand Down Expand Up @@ -239,6 +252,12 @@ resource "fastly_service_vcl" "cache" {
status = 404
}

cache_setting {
name = "cache-nar"
cache_condition = "is-nar"
ttl = 31557600 # the maximum. 1 year
}

# Authenticate Fastly<->S3 requests. See Fastly documentation:
# https://docs.fastly.com/en/guides/amazon-s3#using-an-amazon-s3-private-bucket
snippet {
Expand Down
Loading