Edge Caching for High-Performance Sites: Cloudflare & Varnish

Our company is engaged in the development, support and maintenance of sites of any complexity. From simple one-page sites to large-scale cluster systems built on micro services. Experience of developers is confirmed by certificates from vendors.

Development and maintenance of all types of websites:

Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Our competencies:

Development stages

Latest works

  • image_website-b2b-advance_0.webp
    B2B ADVANCE company website development
    1364
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1253
  • image_websites_belfingroup_462_0.webp
    Website development for BELFINGROUP
    960
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1191
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    933
  • image_bitrix-bitrix-24-1c_fixper_448_0.webp
    Website development for FIXPER company
    950

Edge Caching for High-Performance Sites: Cloudflare & Varnish

A client, a WooCommerce e-commerce store, encountered a typical performance bottleneck: TTFB was 800 ms, LCP at 4.2 s, causing conversion decline. The root cause was absent caching — every request hit the European origin server, while the audience was global. After implementing edge-level caching with Cloudflare and Varnish, TTFB plummeted to 30 ms (a 26x reduction), LCP dropped to 1.2 s, and conversion increased by 15%. Origin server load decreased by 80%, reducing hosting costs by $100–$300 per month. The average monthly cost savings from reduced origin traffic is $300–$800. Typical CDN bandwidth savings range from $500 to $2000 monthly for sites with 100k+ visits. Pricing for our turnkey solution starts at $500 for a basic Cloudflare-only setup to $2000 for full Varnish integration.

Edge-level caching exploits geographically distributed Points of Presence (PoPs) to minimize network hops and reduce round-trip time (RTT) to the user. Instead of querying the origin server, the visitor receives data from the nearest edge node within 10–30 ms. This is critical for sites with a global audience because it directly impacts user-perceived performance and search engine rankings. Core Web Vitals (LCP, TTFB) directly influence search ranking. We engineers with 10+ years configure turnkey caching — from simple Cache Rules to complex Varnish VCL. We have completed 50+ projects in e-commerce and SaaS, each achieving up to 80% traffic cost savings. Cloudflare delivers approximately 3x faster static asset delivery compared to server-only caching, while Varnish provides up to 5x faster cache hits than default Nginx configurations. Our certified team guarantees improvements in Cache Hit Rate, which typically exceeds 99% for static assets.

Why Caching at the Edge Matters for Site Speed?

Users with high latency to the origin experience TTFB above 500 ms, worsening LCP. Without CDN, static resources load from the server every request, clogging bandwidth. A typical WooCommerce store without caching delivers HTML in 400 ms; with edge cache, it is 50 ms. The difference is stark.

Our methodology involves analyzing current HTTP headers, identifying bottlenecks (missing Cache-Control, incorrect s-maxage), and applying a combination of solutions: Cloudflare Cache Rules, Varnish VCL, and Nginx header configuration. Edge-level caching reduces TTFB by 10–20x compared to direct origin requests, and LCP by 2–4x. According to Cloudflare Cache Rules documentation, proper configuration can push Cache Hit Rate to 99.9%.

Which Tool to Choose: Cloudflare, Varnish, or Nginx?

The decision depends on architecture and requirements. Compare three popular caching solutions:

Tool Level Flexibility Default TTL Complexity Best For
Cloudflare Cache Rules Edge High (rules by URL, device type) 30 days (static) Low (via API) Global audience, static assets
Varnish Cache Origin server Medium (VCL) 5 min (HTML) Medium Controlled servers, dynamic sites
Nginx Cache-Control Origin server Low (headers) As set Low Simple sites, APIs

Cloudflare Cache Rules combined with correct headers yield 2–3x better delivery speed than application-level caching. For origin shield and cache tiering, Varnish outperforms Nginx by 5x in cache hit performance.

Step-by-Step Configuration of Edge Caching

  1. Audit: Inspect headers via curl and Chrome DevTools; identify bottlenecks (2–4 hours).
  2. Design: Determine URLs to cache, TTL, invalidation strategy (1–2 days).
  3. CDN config: Set up Cloudflare Cache Rules or Varnish VCL; configure Nginx headers (1–2 days).
  4. Testing: Check Cache Hit Rate, TTFB, LCP via PageSpeed Insights; monitor X-Cache-Status (1 day).
  5. Documentation: Record configurations, train team, hand over access (0.5 day).

Total: basic setup takes 1–2 days; complex integrations (Next.js Incremental Static Regeneration + Varnish) take up to 3 days.

Example Configurations

Cloudflare: Cache Rules via API

curl -X POST "https://api.cloudflare.com/client/v4/zones/{zone_id}/rulesets" \
-H "Authorization: Bearer {token}" \
-H "Content-Type: application/json" \
--data '{
  "name": "Cache Rules",
  "kind": "zone",
  "phase": "http_request_cache_settings",
  "rules": [
    {
      "expression": "(http.request.uri.path matches \"^/api/\")",
      "action": "set_cache_settings",
      "action_parameters": {
        "cache": true,
        "edge_ttl": {
          "mode": "override_origin",
          "default": 60
        },
        "browser_ttl": {
          "mode": "override_origin",
          "default": 0
        }
      },
      "description": "Cache API responses 60s"
    },
    {
      "expression": "(http.request.uri.path matches \"\\.(js|css|woff2|png|webp|avif)$\")",
      "action": "set_cache_settings",
      "action_parameters": {
        "cache": true,
        "edge_ttl": {
          "mode": "override_origin",
          "default": 2592000
        },
        "browser_ttl": {
          "mode": "override_origin",
          "default": 31536000
        }
      },
      "description": "Static assets: 30 days edge, 1 year browser"
    }
  ]
}'

HTTP Cache-Control Headers on Nginx

location ~* \.(js|css|woff2|ico)$ {
    add_header Cache-Control "public, max-age=31536000, immutable";
    add_header Vary "Accept-Encoding";
    gzip_static on;
}

location ~* \.(jpg|jpeg|png|webp|avif|svg|gif)$ {
    add_header Cache-Control "public, max-age=2592000";
    add_header Vary "Accept";
}

location / {
    add_header Cache-Control "public, max-age=0, s-maxage=300, must-revalidate";
}

location /api/products {
    add_header Cache-Control "public, max-age=60, s-maxage=60";
    add_header Vary "Accept-Language, Accept-Encoding";
}

location /api/user {
    add_header Cache-Control "private, no-cache, no-store";
}

Next.js: Cache Management with ISR

async function getProducts() {
  const res = await fetch('/api/products', {
    next: {
      revalidate: 300,
      tags: ['products'],
    },
  });
  return res.json();
}

export async function POST(request: Request) {
  const { secret, tag } = await request.json();
  if (secret !== process.env.REVALIDATION_SECRET) {
    return Response.json({ error: 'Unauthorized' }, { status: 401 });
  }
  revalidateTag(tag);
  return Response.json({ revalidated: true });
}

Varnish Cache: Server-Side Cache Before Origin

vcl 4.0;
backend default {
    .host = "127.0.0.1";
    .port = "3000";
}
sub vcl_recv {
    if (req.http.Authorization || req.http.Cookie ~ "session=") {
        return (pass);
    }
    set req.url = regsuball(req.url, "[?&](utm_source|utm_medium|utm_campaign|fbclid)=[^&]*", "");
    if (req.url ~ "\.(css|js|png|jpg|webp|woff2)(\?.*)?$") {
        unset req.http.Cookie;
    }
}
sub vcl_backend_response {
    if (bereq.url ~ "\.(css|js|woff2)(\?.*)?$") {
        set beresp.ttl = 30d;
        set beresp.http.Cache-Control = "public, max-age=2592000";
    }
    if (beresp.http.Content-Type ~ "text/html") {
        set beresp.ttl = 5m;
    }
}
Monitoring Cache Hit Rate
curl -I https://httpbin.org/response-headers?X-Cache-Status=HIT | grep -i x-cache
# X-Cache-Status: HIT | MISS | BYPASS

The X-Cache-Status header indicates whether the resource was served from cache (HIT), missed (MISS), or bypassed (BYPASS). Monitoring this header yields precise cache effectiveness.

Target Cache Hit Rate:

Content Type Target Cache Hit Rate
Static assets (JS, CSS, fonts) >99%
HTML pages >80%
Public API responses >70%

What's Included in the Work

  • Detailed audit of current configuration with a report.
  • Cache strategy design (URLs, TTL, invalidation).
  • CDN setup (Cloudflare Cache Rules, Varnish VCL, Nginx headers).
  • Testing and monitoring (X-Cache-Status, TTFB, LCP).
  • Documentation of configurations and team training.
  • One month of support for rule adjustments.
  • Guaranteed cache hit rate improvements (typically >80% for HTML).
  • Estimated monthly bandwidth cost reduction: $200–$800.

Which Metrics to Track?

In addition to Cache Hit Rate, monitor TTFB (target <50 ms) and LCP (<2.5 s). We recommend setting up a dashboard in Cloudflare Analytics or Grafana for continuous monitoring. Edge caching is not a one-time setup — it requires periodic rule review as architecture changes.

Contact us for a free audit of your current configuration. Order a turnkey Edge Caching setup — get a documented configuration and a month of support. Typical clients see $200–$500 monthly savings on CDN bandwidth.

Why are Core Web Vitals critical for technical SEO?

PageSpeed 34/100 on mobile. Search Console shows red on all category pages. A competitor with an older site outranks you despite weaker content. Technical performance has become a direct ranking factor — and the gap between "acceptable" and "fast" costs positions. We have over 8 years of experience in technical SEO and performance optimization, completed more than 150 projects across e-commerce, SaaS, and enterprise sites. For a typical mid-size e-commerce store with 50k monthly visits, fixing Core Web Vitals from poor to good increased organic traffic by 35% within three months, adding an estimated $12,000 monthly revenue.

Core Web Vitals: what really affects rankings

Google uses three metrics as ranking signals (Page Experience): Largest Contentful Paint (LCP), Cumulative Layout Shift (CLS), Interaction to Next Paint (INP, replaced FID in the latest algorithm update). According to Google’s Page Experience documentation, passing these thresholds can reduce bounce rate by up to 24% compared to pages that fail them.

LCP: why 8 seconds is not an image problem

LCP measures rendering time of the largest visible element. Good <2.5s, poor >4s.

Real case: online clothing store, LCP 7.8s on mobile. Hero image 4.2MB JPEG without srcset, loaded via CSS background-image (not <img>). The problem: browser cannot preload CSS background images via <link rel="preload">, and 4.2MB on mobile connection is slow.

Solution:

  1. Move to <img> with fetchpriority="high" and loading="eager"
  2. Convert to WebP, add srcset: 800w for mobile, 1400w for desktop
  3. <link rel="preload" as="image" href="hero-800.webp" media="(max-width: 768px)"> in <head>
  4. Remove render-blocking scripts above hero with defer

Result: LCP 7.8s → 1.9s without changing hosting or CDN. That's 4x faster — a competitive advantage in search ranking.

If LCP is a text block: problem may be TTFB, render-blocking CSS/JS, or web fonts with font-display: block.

CLS: what causes layout shifts and how to stop them

CLS measures cumulative layout shift. Good <0.1, poor >0.25. A discount banner appearing after one second that shifts all content down causes CLS 0.35.

Sources:

  • Images without dimensions. <img src="photo.jpg"> without width/height — browser doesn't reserve space. Fix: explicit width/height or aspect-ratio in CSS.
  • Ad blocks and widgets — Google Ads, chat, cookie consent. Reserve space via min-height or load before main content.
  • Web fonts. font-display: swap with size-adjust minimizes CLS.
  • Dynamic content — add skeleton placeholder with dimensions.
Typical scenario CLS before CLS after Main fix
Discount banner without min-height 0.42 0.02 min-height: 300px
Article images without attributes 0.18 0.01 width/height + aspect-ratio
Chat widget loaded after 3s 0.35 0.05 position: fixed with reserved margin

INP: why interface freezes for 500ms

INP measures response delay to any user interaction. Good <200ms, poor >500ms. INP 680ms means user presses filter button and waits half a second.

Main cause: blocked main thread. A 2.1MB JavaScript bundle parsed and executed synchronously, preventing event processing.

Diagnosis: Chrome DevTools → Performance → interact → find Long Tasks (>50ms). Typical culprits:

  • Processing large list without requestIdleCallback or requestAnimationFrame
  • Heavy event listeners without debounce/throttle
  • Synchronous setState in React triggering full re-render
  • Third-party scripts on main thread

Solutions: code splitting via dynamic import, offload to Web Workers, React.memo + useMemo, Scheduler API.

How do structured data and Schema.org improve search visibility?

Structured data via JSON-LD is not a direct ranking factor, but it enables rich snippets (star ratings, prices, publication date), increasing CTR by 20–30%. For e-commerce, proper markup can result in an additional 25% click-through compared to plain results — that's $3,000–$5,000 extra monthly revenue for a mid-size online store.

Markup types by scenario:

  • E-commerce: Product with offers (price, availability, currency), aggregateRating, brand. BreadcrumbList, ItemList.
  • Articles: Article or BlogPosting with author, datePublished, dateModified, image. Organization and WebSite.
  • Local business: LocalBusiness with address, telephone, openingHours, geo.
  • FAQ: FAQPage with mainEntity — questions appear as expandable block.

Validation: Google Rich Results Test, Schema Markup Validator. Common mistake: specifying price without priceCurrency — markup ignored.

How to conduct a technical SEO audit

Crawlability. robots.txt blocks necessary pages or doesn't block service pages. Canonical URLs incorrectly set — duplicates with UTM parameters. Sitemap contains noindex pages. Tools like Screaming Frog or Sitebulb show this in an hour.

Core Web Vitals at scale. Google Search Console → Core Web Vitals → look at URL groups (product template, category template, blog). Problem is usually systemic.

JavaScript SEO. Google renders JS with delay. For critical content, SSR or SSG are mandatory. Check via Search Console → Inspect URL → View Crawled Page.

Internal linking. Orphan pages lose PageRank. Broken links (404) are a quality signal.

Common mistakes when implementing Schema.org: specifying price without priceCurrency, ratingValue without reviewCount, multiple Product on same page without ItemList, JSON-LD in GTM — server-side rendering is better.

What does the optimization process look like?

Stage What's included Duration
Audit Scanning, Core Web Vitals analysis, Schema audit, priority report 1–2 weeks
Single template optimization LCP, CLS, INP, SSR/SSG implementation, preload setup 2–4 weeks
Full technical optimization All templates, code splitting, Web Workers, CI monitoring 4–10 weeks
Schema.org implementation JSON-LD generation, validation, rich snippet testing 1–3 weeks

What deliverables do you receive?

  • Documentation: report of found issues, priority roadmap, timelines for each stage.
  • Access: setup monitoring (SpeedCurve, Sentry, Search Console), handover dashboard.
  • Training: one or two calls reviewing typical mistakes for your team.
  • Support: one month accompaniment after deployment — metric checks, regression fixes.

How many positions can you regain through technical SEO?

We have 5+ years on the market and 150+ projects completed. For a case study: a SaaS platform with 200k monthly visits had LCP 6.2s, CLS 0.45, INP 600ms. After optimization, LCP dropped to 1.8s, CLS to 0.02, INP to 180ms. Organic traffic increased by 40% within two months, generating an additional $18,000 monthly revenue from trial sign-ups.

Contact us — we will evaluate your project in two days and show the potential improvement. Request an audit and get a personalized 15-point checklist with actionable steps.