Inicio - Documentación - POM Cache - 09 Developers - Classify tracking parameters and request headers

Classify tracking parameters and request headers

POM Cache uses query parameters and the HTTP Accept header to decide whether a request can share an HTML representation. These filters change request classification, so use them only for properties with a stable public meaning.

Add a tracking-only query parameter

Known tracking parameters can be removed from the cacheable request so marketing attribution does not create or bypass otherwise identical HTML.

add_filter(
    'pom_cache_tracking_parameters',
    static function ( $parameters ) {
        $parameters[] = 'campaign_source';

        return array_values( array_unique( $parameters ) );
    }
);

Adding campaign_source asserts that:

/offers/?campaign_source=newsletter

has exactly the same public representation as:

/offers/

Do not classify parameters that affect language, currency, price, search, pagination, filters, authentication, preview state, experiments, consent, or content. If a request contains any non-tracking query parameter, POM Cache leaves it dynamic rather than forcing it into the canonical cached page.

Test canonicalization

For every added key:

  1. compare the response body with and without the parameter;
  2. repeat for all parameter values;
  3. confirm that no JavaScript bootstrap data changes;
  4. verify cookies, redirects, and headers;
  5. test the origin before a CDN;
  6. ensure analytics collection still works at the layer that owns it.

If the parameter can ever select different content, remove it from this filter.

Extend JSON-like Accept detection

POM Cache treats requests advertising JSON-like media types as non-HTML. The defaults are:

  • application/json;
  • application/activity+json;
  • application/ld+json.

Add another media fragment when a custom endpoint negotiates a non-HTML representation:

add_filter(
    'pom_cache_accept_headers',
    static function ( $media_types ) {
        $media_types[] = 'application/vnd.example.catalog+json';

        return array_values( array_unique( $media_types ) );
    }
);

This narrows HTML eligibility. Removing a default or returning an incomplete list is dangerous because a JSON response could then be handled as an HTML candidate.

Header matching details

POM Cache compares lowercase Accept content against the configured fragments. Register lowercase media values and do not include unrelated header syntax.

This filter controls HTML classification; it does not create a progressive JSON path, validate a JSON payload, or set CDN cache headers. Use the progressive JSON APIs for those responsibilities.

Timing and deployment

Request normalization can begin during the early drop-in phase. A callback registered by an ordinary plugin may influence WordPress-phase behavior without being available for every earliest cache check.

After changing either filter:

  • clear existing HTML artifacts whose canonicalization changed;
  • review copied Apache rules and CDN cache keys;
  • test clean and parameterized requests;
  • confirm that private or negotiated content cannot reuse an older HTML file.