Skip to content

Commit 4129dec

Browse files
authored
og_image: Ignore CDN invalidation errors (#11521)
The TTL on OG images is low enough that we can ignore invalidation errors. This is particularly relevant for backfilling, where we need to generate a large number of images in short succession.
1 parent b5ec3aa commit 4129dec

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/worker/jobs/generate_og_image.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,20 @@ impl BackgroundJob for GenerateOgImage {
8585

8686
// Invalidate CDN cache for the OG image
8787
let og_image_path = format!("og-images/{crate_name}.png");
88-
ctx.invalidate_cdns(&og_image_path).await?;
88+
89+
// Invalidate CloudFront CDN
90+
if let Some(cloudfront) = ctx.cloudfront() {
91+
if let Err(error) = cloudfront.invalidate(&og_image_path).await {
92+
warn!("Failed to invalidate CloudFront CDN for {crate_name}: {error}");
93+
}
94+
}
95+
96+
// Invalidate Fastly CDN
97+
if let Some(fastly) = ctx.fastly() {
98+
if let Err(error) = fastly.invalidate(&og_image_path).await {
99+
warn!("Failed to invalidate Fastly CDN for {crate_name}: {error}");
100+
}
101+
}
89102

90103
info!("Successfully generated and uploaded OG image for crate {crate_name}");
91104

0 commit comments

Comments
 (0)