Posted On: Jul 24, 2020

Additional geolocation headers are now available in Amazon CloudFront for use in new cache and origin request policies.

You can now configure CloudFront to add additional geolocation headers that provide more granularity in your caching and origin request policies. Previously, you could configure Amazon CloudFront to provide the viewer’s country code in a request header that CloudFront sends to your origin. The new headers give you more granular control of cache behavior and your origin access to the viewer’s country name, region, city, postal code, latitude, and longitude, all based on the viewer’s IP address.

Additional geolocation headers with sample values:

CloudFront-Viewer-Country-Name: United States

CloudFront-Viewer-Country-Region: MI

CloudFront-Viewer-Country-Region-Name: Michigan

CloudFront-Viewer-City: Ann Arbor

CloudFront-Viewer-Postal-Code: 48105

CloudFront-Viewer-Time-Zone: America/Detroit

CloudFront-Viewer-Latitude: 42.30680

CloudFront-Viewer-Longitude: -83.70590

CloudFront-Viewer-Metro-Code: 505

You can use these additional geolocation headers along with the existing supported CloudFront headers to personalize the content that you deliver to your viewers. For example, you can pass the postal-code header to your origin to display hyper-local content or ads. You can also use Lambda@Edge origin request functions to make network calls to pull in local language files and construct and return a language specific HTML page for each country or region.

These additional geolocation headers are now available to use in all Amazon CloudFront distributions at no additional cost.

To use these new headers, see the CloudFront Developer Guide. Learn more about the new cache and origin request policies in our blog. Visit the Lamda@Edge product page to learn more about running code in response to CloudFront events. To learn more about Amazon CloudFront, visit our product page.