Skip to content
The Chat Archive
claude-opus-4-20250514· Anthropic LMArena Human Preference 140K

Think of yourself as an expert Web developer who is aware of the internet engineering…

  1. User

    Think of yourself as an expert Web developer who is aware of the internet engineering task force or IETF RFC documentation and best practices around HTTP headers etc.

    We’re planning to forward geolocation details (City, Region, Country) from the server edge to downstream apps using custom headers.

    We’re considering vendor-neutral headers like: X-Visitor-IP-City X-Visitor-IP-Region X-Visitor-IP-Country Another option is: X-Request-IP-City, etc.

    Are the above good naming conventions?

  2. Assistant

    For custom geolocation headers, I'd recommend moving away from the X- prefix pattern. While X- prefixed headers were historically used for non-standard headers, RFC 6648 (published in 2012) deprecated this convention because it created problems when experimental headers became standardized.

    Instead, consider these alternatives:

    Option 1: Organization-prefixed headers

    MyCompany-Geo-City
    MyCompany-Geo-Region
    MyCompany-Geo-Country
    

    Option 2: Descriptive standalone names

    Geo-City
    Geo-Region
    Geo-Country
    

    Option 3: More specific descriptive names

    Client-Geo-City
    Client-Geo-Region
    Client-Geo-Country
    

    Between your two proposals (Visitor-IP vs Request-IP), I'd lean toward avoiding "IP" in the name since you're conveying geographic information rather than IP addresses. The term "Visitor" is also somewhat ambiguous in HTTP contexts.

    Additional considerations:

    1. Case sensitivity: HTTP header names are case-insensitive, but convention uses Pascal-Case (e.g., Content-Type)

    2. Consider using a single header: You might want to combine all geo data into one header with a structured format:

      Geo-Location: city="San Francisco"; region="CA"; country="US"
      

      or as JSON:

      Geo-Location: {"city":"San Francisco","region":"CA","country":"US"}
      
    3. Use standard country/region codes: ISO 3166-1 alpha-2 for countries (US, GB) and ISO 3166-2 for regions where applicable

    4. Document your headers: Whatever naming convention you choose, ensure it's well-documented for downstream consumers

    The single-header approach tends to be cleaner and reduces header proliferation, but separate headers can be easier to parse in some scenarios. Choose based on your specific use case and consumer needs.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.