---
title: Geolocation
summary: Serve users smarter by making decisions based on where they are in the world.
url: https://www.fastly.com/documentation/solutions/use-cases/geolocation
---


import SolutionsProvider from '~providers/solutions'
import SolutionsTable from '~components/solutions-table/solutions-table'

<p class="lead">Experiences are better when they are local. Knowing the approximate location of an end user allows for localization of content and regulation of access based on regional distribution rights.</p>

![Country switcher](/img/geolocation-hero.png)

## Fastly features

Our geolocation feature, given an IP address, will provide information such as **latitude**, **longitude**, **continent**, **country**, **city**, and **region**, and is exposed in VCL services and all Compute languages. [Learn more about how to use our geolocation features](/guides/concepts/geolocation). Here's an example of a geolocation dataset for an IP address belonging to an AWS server in Tokyo, Japan:

```json
{
  "as_name": "amazon.com inc.",
  "as_number": 16509,
  "area_code": 0,
  "city": "tokyo",
  "conn_speed": "broadband",
  "conn_type": "wired",
  "continent": "AS",
  "country_code": "JP",
  "country_code3": "JPN",
  "country_name": "japan",
  "latitude": 35.68,
  "longitude": 139.75,
  "metro_code": 392001,
  "postal_code": "100-0001",
  "proxy_description": "cloud",
  "proxy_type": "hosting",
  "region": "13",
  "utc_offset": 900
}
```

## Ideas and typical uses

Geolocation data can be used for a wide variety of purposes:

- Display data-collection or cookie consent content that is relevant to the end-user's country.
- Redirect to a local domain or edition of your website, or offer an option to the user to do so.
- Provide localized stock levels or delivery options.
- Block traffic from regions where you are not licensed to deliver content.
- Block regions that are originating DDoS attacks, or subject requests from those regions to additional checks, such as a [CAPTCHA](/solutions/examples/captcha-challenge).
- Trigger additional security measures if a user accesses your site from a different country to the one they are normally in.
- Report geolocation data as part of your [request logging](/guides/integrations/non-fastly-services/developer-guide-logging) to better understand your customers.
- Make an API endpoint for your front end code to use to get access to geolocation data in the browser or your client-side app.

### Cache variation

Many common use cases for geolocation involve sending geo data to an origin server in an HTTP header ([see example](/solutions/examples/decorating-origin-requests-with-geoip)), and using that information to customize the response. In these cases, ensure that the response has an appropriate `Vary` header, or make it [not cacheable](/guides/concepts/cache/cache-freshness).

## Solutions

<SolutionsProvider useCase='geolocation' render={(nodes) => (
  <SolutionsTable nodes={nodes} />
)} />

## Real world usage

Geolocation is one of the most popular uses of Fastly and a very large number of our customers make use of geo data as part of their services. Here are some featured use cases:

### Financial Times

World-leading business news provider the [Financial Times](https://www.ft.com) forwards requests to different origin servers depending on where in the world the request originates. Because they have origin servers in multiple locations, using country and continent geolocation data, they can choose to route requests from the edge to an origin server closer to the user.

### The Weather Channel

The [Weather Channel](https://www.weather.com) redirects homepage requests to a URL that provides a forecast for the user's location, down to the city level.

### The Guardian

The [Guardian](https://www.theguardian.com) uses the location of the user to determine whether to show the US, UK or Australian edition of the website.

### 1stDibs

[1stdibs](https://www.1stdibs.com/) is the world’s leading online marketplace for rare and desirable objects. They use geolocation data as part of their DDoS mitigation. With geography detection, they can quickly identify and block malicious IP addresses during DDoS attacks.

> Fastly’s technology allows us to handle attacks better than anything else while still giving us control.

## Best practices

Here are some of the most important things to bear in mind when you use geolocation in your Fastly services:

- **Continents are not standardized:** Continent designations are not widely used standards and are best avoided. Notably, the continent of Europe is not the same as the political entity of the European Union.
- **Don't use geolocation for language:** Remember, the ability to speak a language is a property of a person, not the place where they are currently located. If possible, use the `Accept-Language` header to customize language preferences.

## Blogs and articles

- [Improve performance and gain better end user intelligence with GeoIP / Geography Detection](https://www.fastly.com/blog/improve-performance-and-gain-better-end-user-intelligence-geoip-geography-detection)
- [Restricting access to content](https://www.fastly.com/blog/restricting-access-content)
