Skip to content

IP geolocation

The VIP edge cache respects a set of geolocation response headers that make it possible to deliver variations of cached content based on the end user’s global location. Logic at the edge leverages the geolocation response headers to determine which specific cached version will be delivered in a response.

Limitations

  • Vary responses should be limited to a specific set of page URLs that absolutely require it. Adding a Vary response for every page can negatively affect the page cache hit ratio and overall performance of a site. For Node.js applications built on Next.js, the source property can be utilized to match specific paths.
  • Geolocation on the VIP Platform is not reliable for sites behind a reverse proxy. Requests that pass through a reverse proxy for a site on VIP will have the remote IP address of the reverse proxy instead of the requester’s IP address. When using a reverse proxy, it is possible that the correct country might be served to the end user, but in most cases, it will be incorrect.

Geolocation headers

Geolocation response headers can be used by both WordPress and Node.js applications.

Each geolocation response header has a corresponding superglobal variable that can be used by WordPress applications in PHP.

This recognized set of location response headers is powered by the Maxmind GeoIP® database and kept current by WordPress VIP.

Response header (Node.js)Superglobal variable (WordPress)Description
x-continentGEOIP_CONTINENTA two-character code for the continent
x-country-codeGEOIP_COUNTRY_CODEISO 3166-1 country code
x-regionGEOIP_REGIONRepresents a ISO 3166-2 code of a first level subdivision
x-metro-codeGEOIP_METRO_CODEThe metro code of the location associated with the IP address. Only valid if the location is within the United States. These codes are consistent with the metro_codes used by Google AdWords API.
x-cityGEOIP_CITYCity name
x-postal-codeGEOIP_POSTAL_CODEThe postal code of the location associated with the IP address. Postal codes are not available for all countries. In some countries, this will only contain part of the postal code.

x-continent response header

The value of the x-continent HTTP response header is a two-character code for the continent associated with the IP address.

x-continent responseResponse description
AFAfrica
ANAntarctica
ASAsia
EUEurope
NANorth America
OCOceania
SASouth America
All possible values for the x-continent HTTP response header and their descriptions

Geolocation in PHP

WordPress applications on the VIP Platform can leverage the predefined superglobal variables for geolocation. For example, to vary the cache for users based on their city, logic in the application’s code can leverage:

$_SERVER['GEOIP_CITY']

All cached geolocation versions of a page or a post’s URL will be invalidated when that page or post is updated.

VIP Go Geo Uniques plugin

The VIP Go Geo Uniques plugin is specifically designed for WordPress sites on the VIP Platform and is currently limited to leveraging the $_SERVER['GEOIP_COUNTRY_CODE'] superglobal described above.

A default country code and a list of supported country codes must be configured for the plugin to efficiently deliver different versions of content from the page cache to users based on location. More detailed instructions for installation and usage can be found in the plugin’s GitHub repository.

Geolocation for Node.js

Node.js applications can read the location data of a request from the corresponding location header.

The exact methods required to read the value of the geolocation response headers and to set response headers to vary the cache is specific to an application’s Node.js framework. To identify the correct method, search the framework’s documentation for terms similar to “setting response headers”.

Example code in the vip-go-node-skeleton repository demonstrates passing a request object to the server as req. In that use case, the country code value of a request can be be retrieved with:

req.headers['x-country-code']

Last updated: September 16, 2025

Relevant to

  • Node.js
  • WordPress