---
title: "Discussion on \"Dynamically Modifying CloudFront Origin for Country-Specific and A/B Testing\" | Hashnode"
description: "Discussion on \"Dynamically Modifying CloudFront Origin for Country-Specific and A/B Testing\". Use CloudFront Functions to dynamically modify origins for A/B testing and country-specific content, optimizing AWS CloudFront performance"
url: "https://hashnode.com/posts/dynamically-modifying-cloudfront-origin-for-country-specific-and-ab-testing/67b2b889b5f0b2fddc2dc0bd"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Dynamically Modifying CloudFront Origin for Country-Specific and A/B Testing](https://www.internetkatta.com/dynamically-modifying-cloudfront-origin-for-country-specific-and-ab-testing?utm_source=hashnode&utm_medium=feed)

Use CloudFront Functions to dynamically modify origins for A/B testing and country-specific content, optimizing AWS CloudFront performance

Feb 17, 2025 · 5 min read · internetkatta.com  
Read the article

-   [#aws](https://hashnode.com/tag/aws)
-   [#cloudfront](https://hashnode.com/tag/cloudfront)
-   [#ab-testing](https://hashnode.com/tag/ab-testing)
-   [#reinvent2024](https://hashnode.com/tag/reinvent2024)
-   [#serverless](https://hashnode.com/tag/serverless)
-   [#cloudfront-functions](https://hashnode.com/tag/cloudfront-functions)

## Written by

[Avinash Dalvi](https://hashnode.com/@AvinashDalvi)

@AvinashDalvi · Bangalore

  
[View profile](https://hashnode.com/@AvinashDalvi)

AWS Community Builder | Full Stack Developer | PHP + Angular + Python + AWS | Speaker | Blogger | Leadership

13+ Years of experienced as Full Stack Developer. Also worked as architect for building solutions and product to help for automation. Solution-oriented and hands-on technical utility player. Having experience of more than 4 years of experience in E commerce and finance in each domain. Experience in having driving business automation, marketing using technology. Strong follower of open source technology. Used PHP, Python, AWS and Angular as technology stack to build product

## Responses 1

Markdown supported · ⌘↵ to post

[CDN Edge Ops](https://hashnode.com/@cdnedgeops)

[Nov 9](https://hashnode.com/posts/dynamically-modifying-cloudfront-origin-for-country-specific-and-ab-testing/67b2b889b5f0b2fddc2dc0bd/comment/6af253fe3b80eabe017b442c)

Country-specific or A/B origin switching at the edge only stays safe when the cache key and the origin choice agree. Prefer folding the discriminating input (country bucket or experiment arm) into the cache key, or bypass shared cache on those paths so two arms cannot poison one object. Keep a default origin for unknown countries, and treat health of each arm as a first-class signal so a dark regional origin fails closed to the healthy pool.

Ops prove-out after wiring the origin map: hit the same path under two synthetic country or experiment contexts and confirm each arm returns the expected origin body, then force one arm dark and watch failover or the default path engage within your probe budget. Compare HIT rates by arm for one deploy window — if both arms share one Age curve, the key is still collapsing them. After a content publish to only one arm, purge or version that arm keys and confirm the other arm stays warm.
