If your CDN cache hit ratio is lower than expected, the problem is rarely the CDN alone. It usually comes down to what you cache, how your cache key is built, which headers and cookies are forwarded, and how often you force the edge to go back to origin. This guide explains how to improve cache hit ratio in a way that remains useful across providers, whether you use Cloudflare caching, a reverse proxy cache, or another CDN for websites. The goal is practical: increase origin offload, reduce avoidable misses, and improve website speed optimization without serving the wrong content to the wrong users.
Overview
A cache hit ratio tells you how often a request can be served from cache instead of from origin. A higher ratio usually means better cache efficiency, lower origin load, and more stable performance under traffic spikes. It can also help improve TTFB for cacheable content because the request is handled closer to the user.
But a high number by itself is not the whole goal. Some requests should never be cached: authenticated pages, carts, checkout flows, account dashboards, and highly personalized API responses are common examples. A healthy CDN cache hit ratio comes from distinguishing cacheable traffic from traffic that must stay dynamic, then making the cacheable portion as reusable as possible.
In practice, most missed opportunities fall into five areas:
- Overly specific cache keys
- Short or inconsistent TTLs
- Unnecessary cookies in requests
- Query strings that fragment otherwise identical content
- Response headers that prevent storage or re-use
Once you understand those five levers, improving edge caching becomes much easier. You do not need to chase every miss. You need to remove avoidable misses from high-volume paths.
Core framework
Use this framework to audit and improve website caching across static assets, HTML, and API responses.
1. Start by separating content types
Do not try to tune the whole site as one bucket. Break traffic into groups:
- Static assets: images, CSS, JavaScript, fonts, PDFs
- Cacheable HTML: home page, marketing pages, blog posts, category pages
- Conditionally cacheable responses: search pages, listings, some API responses
- Bypass content: logged-in areas, cart, checkout, user dashboards, admin paths
This step matters because each group needs different TTLs, bypass rules, and purge behavior. If you mix them together, your CDN optimization rules become hard to reason about.
2. Make the cache key smaller, not dumber
The cache key determines which requests can share the same cached response. By default, many CDNs key on scheme, host, path, and sometimes the full query string. Some setups also vary on headers or device rules.
A low cache hit ratio often means the key is too fragmented. Two requests that should map to the same object end up treated as different because of irrelevant variation.
Review these common key inputs:
- Query strings: marketing tags, sorting parameters, tracking values
- Cookies: analytics, session remnants, plugin cookies
- Headers: Accept-Encoding, Accept-Language, Origin, User-Agent
- Protocol and host: mixed www/non-www or HTTP/HTTPS handling
The rule is simple: include only what actually changes the response body. If a parameter, cookie, or header does not materially change the content, it should not split the cache.
3. Set TTLs that match content reality
Many sites miss on the edge because their TTLs are too cautious. A page that changes twice a week does not need a TTL measured in seconds. On the other hand, a product inventory endpoint may need short freshness windows or revalidation.
Think in layers:
- Long TTL for versioned static assets: ideal for files with hashed filenames
- Moderate TTL for stable HTML: landing pages, evergreen content, documentation
- Short TTL or stale-while-revalidate behavior for semi-dynamic pages: listings, feeds, some API responses
- Bypass for sensitive personalized flows
If you rely on frequent purges, you can usually be more aggressive with TTLs for content that is safe to invalidate on deploy or publish.
4. Forward fewer cookies
Cookies are one of the most common causes of poor cache efficiency. If your CDN sees cookies on every request and assumes the response is user-specific, it may bypass cache or create too many variants.
Audit which cookies are actually needed at the edge. In many setups, most analytics and front-end plugin cookies do not need to reach origin for public pages. Common guidance:
- Bypass cache when true session or auth cookies are present
- Ignore non-essential cookies on anonymous content where safe
- Separate application paths so account areas can bypass without poisoning cacheable pages
WordPress sites are especially prone to cookie sprawl due to themes, plugins, and commerce features. If you run a mixed public and transactional site, strict path-based rules are often cleaner than broad site-wide exceptions. For related patterns, see WooCommerce Caching Rules: What to Cache and What to Bypass and Best WordPress Caching Plugins Compared.
5. Normalize query strings
Query strings are useful, but they often destroy reuse. A page requested with ?utm_source=x should usually share the same cached object as the clean URL. The same is often true for other marketing tags.
Useful patterns include:
- Ignore known tracking parameters
- Sort query parameters into a consistent order
- Whitelist only the parameters that change output
- Treat empty parameters as absent
Be more careful with search, pagination, sort order, and filters. Some of these change the visible page and belong in the key. Others can be normalized to reduce duplication if your application renders equivalent output.
6. Use response headers intentionally
Your origin and CDN should agree about what can be stored and for how long. Review your Cache-Control behavior first. If headers are inconsistent between application paths, the edge will behave inconsistently too.
As a general model:
publicfor content that can be cached by shared caches- Appropriate freshness values for how often content changes
- Revalidation where freshness can be short but content is often unchanged
privateor no-store style handling for personalized responses
If you need a refresher on the mechanics, see HTTP Cache-Control Header Reference for Developers and ETag vs Last-Modified: Which Revalidation Strategy Should You Use?.
7. Reduce origin variation
Sometimes the CDN is configured well, but the origin produces slightly different responses for equivalent requests. Common causes include inconsistent redirects, mixed casing, random response headers, geo logic at origin, or HTML differences caused by plugin state.
Look for:
- Duplicate URLs serving the same content
- Vary headers that are broader than necessary
- Device detection that creates many variants without real benefit
- A/B testing tools that disable caching on every page
The cleaner your origin behavior, the easier it is for edge caching to work predictably.
8. Measure by path, not by site-wide average alone
A site-wide cache hit ratio can hide the real problem. Your overall number may look mediocre because APIs, admin traffic, and authenticated sessions are mixed into the total. Segment your analysis by route class:
- Static asset hit ratio
- Anonymous HTML hit ratio
- API hit ratio by endpoint
- Bypass volume by cookie or path
This helps you find the few high-volume patterns that create most avoidable origin traffic. That is where you will get the biggest gain in origin offload.
Practical examples
These examples show how to apply the framework without depending on one vendor-specific feature set.
Example 1: Marketing site with low HTML hit ratio
A content-heavy site caches images and CSS well, but HTML misses frequently. The likely causes are short TTLs, tracking query strings, and unnecessary cookies from analytics tools.
A practical fix would look like this:
- Cache anonymous HTML at the edge for a moderate TTL
- Ignore
utm_*and other known marketing parameters in the cache key - Bypass only when auth or session cookies are present
- Use a purge workflow on content publish rather than tiny TTLs everywhere
This usually raises the CDN cache hit ratio for public pages without affecting logged-in areas.
Example 2: WordPress site with plugins setting cookies on every page
WordPress caching problems often come from plugins that set cookies globally even when the page is public. The CDN then treats every request as potentially personalized.
What to do:
- Inventory cookies set on anonymous page views
- Identify which cookies are functionally required for public responses
- Bypass cache only for admin, preview, login, cart, account, and checkout paths
- Use edge rules so blog posts, pages, and category archives remain cacheable
If you also run origin caching, make sure your reverse proxy cache rules align with your CDN behavior. See How to Set Up Nginx FastCGI Cache for WordPress for the origin side of that setup.
Example 3: API endpoint with poor cache efficiency
Suppose a public API returns reference data that updates every few minutes, but every request goes to origin. Common reasons include auth headers being forwarded unnecessarily, cache-control being too restrictive, or query parameters creating duplicate keys.
A better API caching strategy may include:
- Cache only safe GET endpoints
- Normalize equivalent query parameters
- Use short freshness plus revalidation for frequently read resources
- Exclude per-user tokens from routes that are actually public
For APIs, correctness matters more than raw hit ratio. But even modest improvements can reduce backend pressure substantially.
Example 4: E-commerce catalog with mixed cacheability
Commerce sites often assume they cannot cache much because cart and account flows are dynamic. In reality, product and category pages are often partly or mostly cacheable for anonymous users, while only a narrow set of paths need strict bypass.
A strong pattern is:
- Cache category and product pages for anonymous traffic
- Bypass cart, checkout, account, and other transactional routes
- Keep personalization out of the main HTML when possible
- Purge affected products or categories on inventory or price change if needed
This approach improves website caching where it counts while protecting transactional correctness.
Common mistakes
Most cache hit ratio problems come from a few repeatable mistakes.
Chasing a perfect ratio
Not all traffic should hit cache. Logged-in users, personalized dashboards, and write-heavy endpoints will lower the overall number. Focus on cacheable request classes, not vanity metrics.
Purging too broadly and too often
If every deploy triggers a full purge, the edge spends much of its time cold. Prefer targeted invalidation where possible. For more on safe invalidation, see How to Purge CDN Cache Without Breaking Your Site.
Varying on everything
Device type, country, language, cookie presence, and full query strings can multiply cache variants quickly. Only vary where the response truly changes.
Ignoring the origin
A CDN cannot compensate for an origin that emits conflicting cache-control headers, unstable redirects, or different HTML for equivalent anonymous requests. Improve origin consistency first.
Letting tools add fragmentation silently
A/B testing tools, personalization scripts, consent managers, and analytics plugins can introduce headers and cookies that reduce reuse. Re-audit after major integrations.
Using the same TTL for everything
Static assets, HTML, APIs, and account pages have different risk profiles. One-size-fits-all caching is easy to deploy and hard to optimize.
When to revisit
Cache behavior should be revisited whenever your application changes in a way that affects reuse, invalidation, or variation. A good rule is to review your edge caching model after any change to URL structure, personalization logic, commerce flows, plugin stack, or CDN provider features.
In practical terms, revisit your setup when:
- You redesign routing, templates, or hostnames
- You add search, filters, faceted navigation, or localization
- You launch WooCommerce or another cart system
- You add feature flags, experiments, or personalization
- You migrate CDN providers or change edge rules
- You see origin costs rising faster than traffic
- You notice hit ratio drops after a deployment
Use this simple review checklist:
- List your top traffic paths by request volume.
- Mark each path as cache, conditional cache, or bypass.
- Inspect the active cache key inputs for each group.
- Remove irrelevant cookies, headers, and query parameters.
- Adjust TTLs to match actual content update patterns.
- Confirm purge workflows are targeted and predictable.
- Measure hit ratio and origin offload by route class, not only globally.
If you are also evaluating providers while tuning policy, compare features around custom cache keys, purge controls, origin shielding, and pricing model rather than judging on headline branding alone. These supporting guides may help: Cloudflare vs Bunny.net vs Fastly: CDN Features and Pricing Compared, Best CDN Services for Small Business Websites, and CDN Pricing Comparison Calculator Inputs: What Costs to Estimate Before You Choose.
The most durable way to improve cache hit ratio is to treat caching as part of application design, not a layer you bolt on at the end. When cache keys are clean, headers are intentional, and bypass rules are narrow, the edge can do its job well. That usually means fewer origin requests, steadier performance, and a CDN setup that is easier to reason about the next time your architecture changes.