Skip to content
Black Friday Save 50% FOREVER Use code BF2026 Ends November 30, 2026 Shop plugins

The Query String That Was Shredding a Store’s Page Cache

A junk currency query parameter being rejected with a 403 before WordPress loads

Some performance problems aren’t about slow code. They’re about too much code running, for visitors who were never going to buy anything. This is a short case study about a multi-currency WooCommerce, running the YITH Multi Currency Switcher for WooCommerce plugin for this purpose, store whose page cache was being quietly destroyed by a single query string, and the tiny guard we wrote to stop it. If you run a multi-currency store, there’s a good chance this is happening to you right now.

The setup: currency as a URL parameter

The site let shoppers browse in their own currency. Like many multi-currency switchers, the plugin accepts the chosen currency as a query parameter, something like ?currency=USD, so the selection can be linked and shared. Perfectly reasonable.

Here’s the catch. A full-page cache treats every unique URL as a separate page. /shop/ and /shop/?currency=USD are two different cache entries. That’s by design since the prices on them differ. With a handful of real currencies, that’s a handful of extra cached variations. No problem.

The symptom: cache hit-rate falling, load climbing

Traffic looked normal. Load did not. The server was doing far more full WordPress and WooCommerce renders than the human traffic justified, and the page cache’s hit-rate was oddly low for a site serving mostly cacheable pages.

The access logs told the story. Bots were hammering the site with requests like:

GET /?currency=XYZ
GET /?currency=0
GET /?currency=aaaa
GET /?currency=<garbage>
GET /?currency=99999
...thousands of distinct, nonsense values...

Each unique ?currency= value is a brand-new URL the cache has never seen. So every one of those requests missed the cache and triggered a full render — booting WordPress, loading WooCommerce, building the theme — just to serve a page to a bot feeding in a currency that doesn’t exist. Worse, each junk response was then stored, polluting the cache with thousands of worthless entries and pushing the real, valuable pages out of it.

It’s a cache-busting flood. The attacker (or just a dumb scraper) doesn’t need to find a slow page — they turn every page into a slow page by making every request unique.

The root cause in one line

The store accepted any value of ?currency= and did expensive work before deciding whether that value was even valid. The set of real currencies is small, known and fixed. Everything outside that set is garbage — but the site was treating garbage exactly like a legitimate request: full render, fresh cache entry, full cost.

The fix: reject garbage before WordPress wakes up

The cheapest request is the one you refuse immediately. We wrote a small must-use plugin, which loads extremely early, before WooCommerce and the theme, that does exactly one thing: if there’s a ?currency= parameter and its value isn’t one of the store’s real, enabled currencies, it returns a 403 with a no-store header and stops. No WooCommerce. No theme. No cache entry.

<?php
/*
 * Plugin Name: Currency Param Flood Guard
 * Description: 403 any ?currency= value that isn't a real, enabled currency,
 *   before WordPress loads WooCommerce or the theme — so junk values can't
 *   bust the page cache or trigger a full render.
 */
if ( ! is_admin() && isset( $_GET['currency'] ) ) {

    $allowed = array( 'GBP', 'USD', 'EUR', 'AUD', /* ...your enabled currencies... */ );

    $cur = is_string( $_GET['currency'] ) ? $_GET['currency'] : '';

    if ( ! in_array( $cur, $allowed, true ) ) {
        http_response_code( 403 );
        header( 'Cache-Control: no-store' );
        header( 'Content-Type: text/plain; charset=UTF-8' );
        exit( 'Invalid currency parameter.' );
    }
}

A few details that matter:

  • It’s a must-use plugin, so it runs before regular plugins. The junk request is killed before WooCommerce or the theme ever load. That’s where the saving is.
  • It allowlists, it doesn’t blocklist. You can’t enumerate every bad value, but the set of good values is tiny and known. Anything not on the list is rejected.
  • It only touches the front end (! is_admin()) and only when the parameter is actually present, so real visitors and the admin are completely unaffected.
  • The no-store header makes sure no layer caches the 403 itself against that junk URL.

The result

The flood stopped mattering instantly. Nonsense currency requests now cost a few microseconds of PHP and return a flat 403 instead of spinning up the entire stack and poisoning the cache. The cache went back to holding the pages real customers actually request, hit-rate recovered, and the baseline server load dropped back to where the genuine traffic put it.

The general lesson: validate anything that forks your cache

Any query parameter that changes what a page returns also changes its cache key — and that makes it a lever. If a parameter can take unlimited values and each one triggers real work, an attacker can multiply your most expensive operation by simply iterating. The defence is boring and effective:

  • Identify the query parameters that affect your output or your cache key (currency, language, affiliate/UTM tags, sort orders, filters).
  • For the ones with a small, known set of valid values, validate against an allowlist as early as possible, ideally before the framework fully loads.
  • Reject the invalid ones cheaply, and make sure nothing caches that rejection against the junk URL.

It’s a handful of lines, but it changes the economics: the bot’s cheapest move is no longer your most expensive one.

If your store is under this kind of low-grade, persistent pressure — the sort that never quite breaks anything but keeps your load mysteriously high, this is the kind of thing we enjoy hunting down.