Skip to content

This page covers the self-hosted EdgeComet engine, the open-source core you run on your own servers. For EdgeComet cloud, see Cache key: one copy per URL and device profile.

URL normalization ​

Overview ​

URL normalization ensures that different URL variations pointing to the same content share a single cache entry. Proper normalization reduces the number of renders and decreases cache storage usage.

Many query parameters serve only tracking or marketing purposes. Parameters like utm_source, utm_content, and fbclid do not affect page content and can be stripped before caching.

Other parameters affect content but their order does not. For example, ?sort=price&limit=10 and ?limit=10&sort=price return identical results. Edge Gateway automatically sorts query parameters alphabetically, ensuring both URLs generate the same cache key.

Normalization rules ​

Scheme ​

  • Converted to lowercase
  • URLs without scheme default to https://

Host ​

  • Converted to lowercase
  • Trailing dots removed (example.com. → example.com)
  • Default ports removed (:80 for HTTP, :443 for HTTPS)

Path ​

  • Empty paths become /
  • Percent-escapes decoded (/caf%C3%A9 → /café; /a%2Cb and /a%2cb → /a,b), so every spelling of a path shares one cache entry. A path that would decode to invalid UTF-8 (for example %FF) keeps its escaped form
  • Duplicate slashes collapsed (// → /)
  • Relative segments resolved (. and ..). This runs after decoding, so %2F acts as / and %2E%2E as ..
  • Trailing slashes preserved

The decoded path is the cache key. The origin can receive a different spelling, see What the origin receives.

Query parameters ​

  • Parameters sorted alphabetically by key
  • Multiple values for same key preserved in original order
  • Names and values re-encoded with uppercase hex (a=1,2 → a=1%2C2, q=%ce%b1 → q=%CE%B1, a space → +)
  • Empty values handled (?key vs ?key=)

Fragments ​

  • Removed by default (content after #)

Non-ASCII characters ​

  • Paths: decoded to UTF-8 text (/%CE%B1 → /α), as described under Path
  • Query parameter names and values: percent-encoded using UTF-8 with uppercase hex (α → %CE%B1)

Tracking parameter removal ​

Edge Gateway strips common tracking and analytics parameters by default. You can customize this list per host.

Default parameters ​

ParameterSource
utm_sourceGoogle Analytics
utm_contentGoogle Analytics
utm_mediumGoogle Analytics
utm_campaignGoogle Analytics
utm_termGoogle Analytics
gclidGoogle Ads
fbclidFacebook
msclkidMicrosoft Ads
_gaGoogle Analytics
_glGoogle Analytics
mc_cidMailchimp
mc_eidMailchimp
_keKlaviyo
refGeneric referrer
referrerGeneric referrer

Configuration ​

Use params to completely replace the built-in defaults, or params_add to extend them with additional patterns.

yaml
tracking_params:
  params:                       # Replaces all defaults
    - "utm_*"
    - "fbclid"
yaml
tracking_params:
  params_add:                   # Keep defaults, add custom
    - "affiliate_id"
    - "tracking_*"

Host-level configuration adds to global parameters:

yaml
hosts:
  - domain: example.com
    id: 1
    render_key: "secret-key"
    tracking_params:
      params_add:
        - "custom_param"
    render:
      timeout: 30s
      # ... other host settings

To disable tracking parameter stripping entirely:

yaml
tracking_params:
  strip: false
yaml
hosts:
  - domain: example.com
    id: 1
    render_key: "secret-key"
    tracking_params:
      strip: false
    # ...

URL pattern level configuration for specific paths:

yaml
hosts:
  - domain: example.com
    id: 1
    render_key: "secret-key"
    url_rules:
      - match: "/api/*"
        action: "bypass"
        tracking_params:
          strip: false              # Keep all params for API
      - match: "/campaigns/*"
        action: "render"
        tracking_params:
          params_add:
            - "campaign_*"          # Strip additional params

Configuration follows the standard hierarchy: Global → Host → URL pattern. Parameters accumulate down the hierarchy when using params_add. Use params at any level to discard all inherited parameters and start fresh with only the specified list.

Pattern types ​

TypeSyntaxExampleCase
ExactNo prefix"fbclid"Insensitive
Wildcard*"utm_*"Insensitive
Regexp~ prefix"~^gclid.*"Sensitive
Regexp~* prefix"~*^gclid.*"Insensitive

Cache key generation ​

After normalization, Edge Gateway generates a hash using XXHash64. This hash becomes part of the Redis cache key and HTML filename.

  • Algorithm: XXHash64 (fast, non-cryptographic hash)
  • In-memory type: uint64
  • Serialized format: decimal uint64 everywhere — Redis cache keys, on-disk filenames, JSON APIs, structured logs, and event log lines (e.g., 11399234567890123456)
  • Deterministic: Same normalized URL always produces same hash

Example transformation:

Input:  HTTPS://Example.Com:443/path//to/../page?z=1&a=2&utm_source=google#section
Output: https://example.com/path/page?a=2&z=1
Hash:   11651889946454949520

The hash is used in:

  • Redis key: cache:{host_id}:{dimension_id}:{hash}
  • Filename: {hash}_{dimension}.html

Normalization examples ​

Input URLNormalized URLNotes
HTTP://EXAMPLE.COM/Pagehttp://example.com/PageScheme/host lowercased, path case preserved
https://example.com:443/https://example.com/Default port removed
example.com/path//filehttps://example.com/path/fileScheme added, double slash collapsed
https://example.com/a/../bhttps://example.com/bParent reference resolved
https://example.com/page?b=2&a=1https://example.com/page?a=1&b=2Query params sorted
https://example.com/?a=2&b=1&a=1https://example.com/?a=2&a=1&b=1Multiple values preserved
https://example.com/page?utm_source=googlehttps://example.com/pageTracking param stripped
https://example.com/page?id=5&fbclid=abc123https://example.com/page?id=5fbclid stripped, id preserved
https://example.com/?gclid=xyz&ref=twitter&q=testhttps://example.com/?q=testMultiple tracking params stripped
/path?b=2&a=1ErrorMissing host

What the origin receives ​

The normalized URL is the cache key, not always the URL Edge Gateway fetches. Origins can treat spellings of one path differently: some answer /a,b with a 301 to /a%2Cb, and fetching the decoded path would send the bot a redirect to the URL it requested. So when it is safe, Edge Gateway sends the origin the path as the bot spelled it, on render, bypass and recache:

  • Percent-escapes keep their spelling and hex case (%2C stays %2C, %2c stays %2c)
  • Escapes of unreserved characters (letters, digits, -, ., _, ~) are decoded (%41 → A, %7E → ~), as before
  • Scheme, host and query come from the normalized URL: the query is sorted and tracking parameters are stripped

Edge Gateway sends the normalized path instead when the received path:

  • contains //, a . or .. segment, %2F, %2E or %5C (any hex case), or a raw \
  • contains a raw character other than letters, digits, -._~ and $&+,;=:@/, for example !, ', (, ), *, [, ], |, a space or non-ASCII text
Path receivedPath sent to the originCache key path
/blog/a%2Cb/53/blog/a%2Cb/53/blog/a,b/53
/blog/a%2cb/53/blog/a%2cb/53/blog/a,b/53
/blog/a,b/53/blog/a,b/53/blog/a,b/53
/caf%C3%A9/caf%C3%A9/café
/p%3Fq/p%3Fq/p?q
/x%7Ey/x~y/x~y
/a//b%2Ccnormalized path/a/b,c
/a!bnormalized path/a!b

The received path is the url parameter after Edge Gateway decodes it once. Integrations that encode the target URL (Cloudflare Worker, CloudFront, Fastly) keep the bot's spelling. The nginx and HAProxy examples pass the target URL unencoded, so escapes in its path are decoded on arrival and the origin receives the decoded path.

Recache has no incoming request, so it fetches the spelling stored with the cache entry by the request that produced it, as long as that spelling still maps to the same cache key. Otherwise it fetches the normalized URL, as it does for a URL that was never requested live.

Cached redirects to the same URL ​

All spellings of a path share one cache entry, so a 301 that the origin returned for /a,b would be served to a request for /a%2Cb and point the bot back at its own URL. When a request keeps its spelling, Edge Gateway ignores a cached 301, 302, 307 or 308 whose Location normalizes to the request's own cache key, unless the same spelling produced it. It fetches the origin instead, and a cacheable response replaces the entry. This also covers lock waiters and stale fallbacks: an ignored entry is never served as stale.

A URL that redirects to itself for its own spelling is fetched once more and then cached and served as usual.

Each request that ignores a cached redirect logs Cached redirect ignored for different spelling at Info and increments eg_cached_redirect_ignored_total{host}.