Optimising Cache Implementation: How to Ignore Marketing Parameters and Save Your Cache

3 minutes read
Optimising Cache implementation
Table of Contents

Introduction

Managing cache in eCommerce often feels like a battle between marketing tracking parameters and cache performance. By default, every new UTM, GTM, or TikTok ID makes the cache think it’s a whole new page, leading to wasted entries and poor hit ratios. Here’s how we spotted the issue and the fix that worked.

The Problem: Cache Pollution from Marketing URLs

Modern ad platforms generate unique identifiers for almost every click. TikTok, for example, can generate a unique GTM ID for each user.

That means these two URLs, identical from a content perspective, end up creating separate cache entries:

/product/shoes?id=123&utm_source=tiktok&utm_id=abc123  

/product/shoes?id=123&utm_source=tiktok&utm_id=xyz456  

For the cache engine, these are two different pages.

Now imagine this at scale. In one campaign, we saw 80,000 unique URLs being called. All of them pointed to the same product page, but the cache treated them as 80,000 separate sessions.

Impact:

  • Cache hit ratio dropped significantly
  • Increased load on origin servers
  • Page speed slowed for users
  • Infrastructure costs spiked

As a quick fix, we scaled up by adding more EC2 servers. It gave us some breathing room, but only temporarily. The underlying issue remained, and costs kept climbing until we addressed the cache rules properly.

How We Detected the Issue

We didn’t catch this immediately. To be honest, everything looked fine until we started digging into the custom NRQL dashboards we had built for observability.

That’s when it became clear:

  • Cache entries were exploding beyond expected levels
  • URL patterns showed that GTM/TikTok parameters were creating unnecessary fragmentation
  • Marketing traffic was literally breaking cache efficiency

Without a dashboard, this would’ve stayed hidden as “random server load issues”.

The Solution: Ignoring Marketing Parameters in Cache Rules

The fix is conceptually simple. Tell your cache engine to ignore certain query parameters. That way, the cache only considers the meaningful part of the URL and treats marketing params as irrelevant noise.

Example:

Without rules, the cache sees these as different:

/category/shoes?utm_source=google  

/category/shoes?utm_source=tiktok  

/category/shoes?utm_source=facebook  

With proper config, the cache sees them as the same:

/category/shoes  

Fastly VCL Example

If you’re on Varnish, you can use VCL snippets like this:

# Remove unwanted query parameters before caching

sub vcl_recv {

    if (req.url.qs) {

        set req.url = querystring.filter(req.url, “utm_source,utm_medium,utm_campaign,utm_term,utm_content,fbclid,gtm_id”);

    }

}

This tells Fastly to ignore everything except the parameters you actually care about.

Magento 2 + Fastly Module

If you’re using Magento 2 with Fastly, you don’t even need custom VCL in most cases. The Fastly module for Magento has an option to configure Ignored Parameters.

Go to:
Stores > Configuration > Advanced > System > Full Page Cache > Fastly Configuration

Here, you can add parameters like:

utm_source  

utm_medium  

utm_campaign  

utm_content  

fbclid  

gtm_id  

Results & Benefits

Once we rolled this out, the difference was instant:

  • Cache hit ratio jumped back up from 80000 to 40 sessions (2000:1)
  • Origin server load dropped
  • Page speed improved for end users

Best Practices for Teams

Here’s what we recommend after this experience:

  • Maintain a shared list of “ignore params” with marketing + dev teams (UTM, GTM, TikTok, fbclid, gclid, etc.)
  • Audit cache metrics regularly using dashboards
  • Document cache policies so new devs don’t have to rediscover the same problem

Conclusion

Marketing campaigns and cache can work together. By ignoring marketing parameters in cache rules, you reduce noise, improve speed, and cut costs without losing tracking data. Before scaling servers, check your cache hygiene. A few smart rules go a long way.

Get eCommerce insights, tips, and best practices.

Picture of Mahaveer Devabalan
Mahaveer Devabalan

With a profound passion for e-commerce and extensive knowledge of Magento (Adobe Commerce), he is a persuasive advocate who utilizes cutting-edge technology to craft exceptional, high-performing online experiences.

You May Also Like

Latest Blogs

Send Feedback

Request PWA Demo