Urgent.News

What's breaking now, across hundreds of outlets.

Tech

Why Your Full-Page Cache Needs an Opinion About Query Strings

Two different incidents on the same WordPress VIP-style multisite network, months apart, turned out to share one root cause. The first was a bot sending Accept: application/json to an ordinary HTML page, silently tripping a content-negotiation guard and getting served an ads-stripped page — which then got written into the full-page cache under the URL's normal key and handed to every real visitor…

Two separate incidents on the same WordPress VIP-style multisite network, months apart, both traced back to a single root cause: a full-page cache key that let the request decide what it meant rather than being designed purposefully. The first incident involved a bot sending Accept: application/json to an HTML page, which triggered a content-negotiation guard and resulted in an ads-stripped page getting cached under the normal URL.

The second incident saw a crawler re-fetching URLs with tracking parameters, each unique value creating its own cache entry, leading to expensive origin renders for URLs that would never be requested again.

The key issue is that a cache key should not be determined by whatever the request contains, but rather be explicitly designed to account for what actually varies the response. A default cache key based solely on the request URL (path plus query string) often assumes that every distinct URL-query string combination yields a different response, which is rarely true. Factors like headers and cookies can influence the rendered response without affecting the underlying URL.

To fix this, known tracking parameters should be stripped from the cache key at the edge/CDN layer before it becomes the key, and any headers that genuinely affect the response should be explicitly varied on. This prevents the cache from serving different cached copies to different users based on request headers or parameters that don't actually change the content.

The solution must be applied uniformly across the system, not patched individually for each site, as incidents can affect multiple sites with similar configurations.

In essence, a well-defined cache key should only include factors that truly determine the response. Query strings are a major source of false cache misses for sites with tracking parameters, so they should be explicitly excluded from the key. Application logic headers that affect the response need to have an explicit Vary directive, or the logic must be changed to stop relying on headers that aren't reliable for caching purposes.

By applying this cache key design principle cluster-wide, similar cache-related issues can be avoided.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

Why Your Slow-Query Log Is Lying to You (a Little)

You've done the obvious work. You pulled a slow-query log off production, found the worst offenders, added indexes, rewrote a couple of queries, and shipped it. Response times improved.

  • Slow-query logs show queries over usual runtime but miss some cases
  • They don't capture rarely hit queries or cache state dependent problems
  • Enable SAVEQUERIES in WordPress for full query profiling during debugging

Cloud costs were never a technology problem

I've been sharing what I see inside cloud accounts for months now Real accounts. Real numbers. Real messes and real fixes Here's what it all adds up to Cloud costs are not a technical problem The…

  • Cloud costs stem from human factors, not technical issues
  • Disconnection between resource provisioners and bill reviewers leads to visibility gaps
  • Regular review and documentation prevent cost crises

Temporal.io vs Cadence vs AWS Step Functions: Distributed Workflow Orchestration & State Durability

Temporal.io vs Cadence vs AWS Step Functions: Distributed Workflow Orchestration & State Durability Executive Summary & Decision Matrix All three systems solve the same core problem — durable…

  • Temporal.io and Cadence share open-source codebase, Temporal forked Cadence in 2019
  • AWS Step Functions is managed, closed-source JSON interpreter relying on AWS durability
  • Temporal/Cadence outperform AWS Step Functions in sustained workflow throughput and lower latency

More from Sunday 22 November →