From dc16684590b43ca717d468fe279afb95bfb9a9bc Mon Sep 17 00:00:00 2001 From: Jacob Hoffman-Andrews Date: Sat, 4 Feb 2023 13:33:49 -0800 Subject: [PATCH] doc.rust-lang.org: immutably cache static files --- terraform/releases/impl/cloudfront-doc.tf | 40 ++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/terraform/releases/impl/cloudfront-doc.tf b/terraform/releases/impl/cloudfront-doc.tf index 62aa05006..8492988f6 100644 --- a/terraform/releases/impl/cloudfront-doc.tf +++ b/terraform/releases/impl/cloudfront-doc.tf @@ -71,7 +71,45 @@ resource "aws_cloudfront_distribution" "doc" { } ordered_cache_behavior { - path_pattern = "*.woff2" + path_pattern = "/nightly/static.files/*" + allowed_methods = ["GET", "HEAD", "OPTIONS"] + cached_methods = ["GET", "HEAD", "OPTIONS"] + target_origin_id = "main" + + response_headers_policy_id = aws_cloudfront_response_headers_policy.cache_immutable.id + cache_policy_id = data.aws_cloudfront_cache_policy.caching.id + + compress = true + viewer_protocol_policy = "redirect-to-https" + + lambda_function_association { + event_type = "origin-request" + lambda_arn = module.lambda_doc_router.version_arn + include_body = false + } + } + + ordered_cache_behavior { + path_pattern = "/beta/static.files/*" + allowed_methods = ["GET", "HEAD", "OPTIONS"] + cached_methods = ["GET", "HEAD", "OPTIONS"] + target_origin_id = "main" + + response_headers_policy_id = aws_cloudfront_response_headers_policy.cache_immutable.id + cache_policy_id = data.aws_cloudfront_cache_policy.caching.id + + compress = true + viewer_protocol_policy = "redirect-to-https" + + lambda_function_association { + event_type = "origin-request" + lambda_arn = module.lambda_doc_router.version_arn + include_body = false + } + } + + ordered_cache_behavior { + path_pattern = "/static.files/*" allowed_methods = ["GET", "HEAD", "OPTIONS"] cached_methods = ["GET", "HEAD", "OPTIONS"] target_origin_id = "main"