Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk11 min

How to Build a Fast WordPress Stack with Nginx, Varnish and Memcached

A practical architecture for combining Nginx, one full-page cache, and Memcached in WordPress without serving stale or personalized content to the wrong visitor.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A fast WordPress deployment uses each component for a different job: Nginx accepts connections and serves static files, one page-cache layer (Nginx FastCGI cache or Varnish) replays complete anonymous responses, and Memcached keeps frequently used WordPress objects and transients in memory. The reliable design is layered, has explicit bypass rules for personalized requests, and has one clear purge path after content changes. Adding every cache without defining ownership can serve stale or private content and can make troubleshooting harder.

What this stack is designed to do

WordPress normally builds a response by running PHP, loading plugins and the theme, querying the database, and rendering HTML. Caching reuses work that has already been done. The WordPress Hosting Handbook describes the principle plainly: “Caching saves time for potentially heavy tasks by reusing previously computed results, rather than calculating them for every page view.”

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The three services operate at different layers:

  • Nginx is the web server. It terminates or passes through connections, serves static assets, and can send PHP requests to PHP-FPM. Its FastCGI cache can store complete HTML responses.
  • Varnish is an HTTP reverse proxy in front of the application. Varnish Configuration Language (VCL) decides which requests pass to WordPress, which responses are stored, which headers are returned, and how objects are purged.
  • Memcached is an in-memory object cache. WordPress can use it through an object-cache drop-in to retain database results, options, and transients between requests. It is not a substitute for a full-page cache.

A cache hit should avoid as much origin work as possible. A miss should still follow a predictable path and never expose one visitor’s personalized response to another.

Request flow and cache boundaries

A practical request path is:

  1. The browser or a CDN connects to the public endpoint.
  2. Nginx accepts the request and serves a static file directly when possible.
  3. A full-page cache answers anonymous GET or HEAD requests. This is either Nginx FastCGI cache or Varnish; running both for the same URL is usually unnecessary.
  4. If the page is not cached, PHP-FPM runs WordPress. An opcode cache, if enabled by the host, keeps compiled PHP bytecode in memory.
  5. WordPress asks its object cache for options, post data, and transients. Memcached can answer repeated lookups without a database round trip.
  6. The database and uncached fragment work complete the response, which then travels back through the page-cache layer.

The Hosting Handbook notes that storage medium, network distance, and I/O latency affect the result. A remote Memcached server can therefore be slower than a local one for small objects, while a properly placed reverse proxy can remove an entire PHP request.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.

Choose one owner for full-page caching

Nginx FastCGI cache and Varnish can both cache complete HTML pages. Decide which layer owns that responsibility before writing configuration. Keep the other component as a pass-through proxy, or omit it unless you need its specific features.

Question Nginx FastCGI cache Varnish
Placement Integrated with the Nginx-to-PHP-FPM path Dedicated reverse proxy in front of the web server or application
Rules Nginx directives, maps, cache keys, and bypass variables VCL subroutines such as vcl_recv, vcl_backend_response, and vcl_deliver
Purge control Filesystem or Nginx purge mechanism, often driven by an authenticated endpoint or deployment hook VCL-driven purge and ban logic; the exact method depends on the Varnish setup
Observability Nginx access logs and headers you add for HIT, MISS, or BYPASS Varnish request logs, response headers, and VCL counters
When it fits A compact topology where Nginx already fronts PHP-FPM A separately managed HTTP cache with detailed request and invalidation policy
Do you need both? Usually no for the same page objects. Two page caches require identical keys, bypass rules, and purge behavior or they will disagree.

There is no universal speed multiplier for this combination. The workload, hit rate, object size, storage, network distance, and configuration determine the result. WordPress.org’s Optimization handbook says static-file caching can improve performance “several hundred times over for fairly static pages”; that is a qualitative statement about static caching, not a benchmark for this complete stack.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Plan the topology before installing services

Define the public and private paths

Decide where TLS terminates, which host is reachable from the internet, and whether Varnish and Nginx run on one machine or separate machines. Exact package versions, Linux distribution commands, PHP-FPM pool sizing, TLS settings, and database tuning depend on the host and are not universal defaults.

Reserve memory deliberately

Memcached, the page cache, PHP-FPM workers, the database, and the operating system all compete for RAM. Set cache limits only after accounting for PHP worker memory and database buffers. Eviction is normal when Memcached reaches its limit; monitor it rather than treating every eviction as a failure.

Pick a cache key

A page-cache key must vary on every input that changes the response. A common starting point includes scheme, host, request method, and normalized URI. Add a deliberate policy for relevant query strings; ignoring a query parameter that changes content can produce incorrect pages, while varying on tracking parameters can destroy the hit rate.

Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.

Configure Nginx and PHP-FPM

Nginx should serve versioned CSS, JavaScript, images, and fonts directly with long-lived browser headers where your deployment process changes the filename when content changes. Dynamic requests are passed to PHP-FPM through FastCGI. Keep the PHP-FPM socket or upstream name, document root, and timeout values specific to your host.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Illustrative FastCGI-cache pattern

The WordPress Nginx handbook documents the cache path, cache key, stale behavior, and bypass conditions. The following is a pattern to adapt, not a copy-and-paste production policy:

fastcgi_cache_path /var/cache/nginx/wordpress levels=1:2 keys_zone=WP:100m inactive=60m use_temp_path=off;
fastcgi_cache_key '$scheme$request_method$host$request_uri';

map $request_method $skip_cache_method {
    default 0;
    POST 1;
}

map $http_cookie $skip_cache_cookie {
    default 0;
    ~*wordpress_logged_in 1;
    ~*comment_author 1;
    ~*wp-postpass 1;
}

location ~ .php$ {
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_pass unix:/run/php/php-fpm.sock;
    fastcgi_cache WP;
    fastcgi_cache_methods GET HEAD;
    fastcgi_cache_bypass $skip_cache_method $skip_cache_cookie;
    fastcgi_no_cache $skip_cache_method $skip_cache_cookie;
    fastcgi_cache_use_stale error timeout updating http_500 http_503;
    add_header X-Cache $upstream_cache_status always;
}

The handbook’s fastcgi_cache_valid 200 60m example demonstrates syntax, not a universal one-hour policy. Set freshness according to how quickly your content must change, and pair it with purge or revalidation so editors do not wait for an arbitrary timeout.

Put Varnish in front when you need VCL control

Varnish can serve a previously built page without executing the Apache, PHP, and WordPress stack. It is useful when you need detailed policy for cookies, URL normalization, grace (serving an older object while the origin is unavailable), bans, or response headers.

Core VCL decisions

At minimum, your VCL should:

  • Pass non-cacheable methods such as POST, PUT, PATCH, and DELETE.
  • Pass administration, login, registration, XML-RPC, and other private endpoints.
  • Pass requests carrying an authenticated WordPress cookie or a password-protection cookie.
  • Decide which query strings are content-bearing and which are tracking noise.
  • Cache only successful, public responses and apply a bounded grace period for origin failures.
  • Expose a safe cache-status header for operations, without leaking cookies or internal hostnames.
sub vcl_recv {
    if (req.method !~ "^(GET|HEAD)$") { return (pass); }
    if (req.url ~ "^/wp-admin/" || req.url ~ "wp-login.php" || req.url ~ "xmlrpc.php") { return (pass); }
    if (req.http.Cookie ~ "wordpress_logged_in_|wp-postpass_|comment_author_") { return (pass); }
}

sub vcl_backend_response {
    if (beresp.http.Set-Cookie || beresp.http.Cache-Control ~ "private|no-cache|no-store") {
        set beresp.uncacheable = true;
        set beresp.ttl = 0s;
        return (deliver);
    }
}

sub vcl_deliver {
    if (obj.hits > 0) { set resp.http.X-Cache = "HIT"; }
    else { set resp.http.X-Cache = "MISS"; }
}

Review the VCL against your plugins. A plugin that sets a cookie on every response can make every page uncacheable; a plugin that varies HTML by a query string needs that variation represented in the cache key or bypassed.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by

Use Memcached for WordPress objects, not anonymous HTML

Memcached is a high-performance distributed memory system intended to reduce database load. WordPress supports it as a popular object-caching engine through an object-cache drop-in. The drop-in stores objects such as options, post metadata, taxonomy data, and transients; it does not decide whether an entire HTML page is safe for all visitors.

Install and verify the object-cache integration

  1. Confirm that the PHP Memcached extension and the Memcached daemon are available on the same network segment, preferably on the same host for low-latency traffic.
  2. Install a WordPress object-cache drop-in compatible with your PHP and WordPress versions. Use one drop-in only; competing object-cache.php files can override each other.
  3. Configure the daemon address, port, key prefix, and timeout in the drop-in or its documented settings. Use a site-specific prefix when several WordPress installations share a daemon.
  4. Check the drop-in’s status page or logs, then watch hit, miss, set, get, and eviction counters while traffic is representative.

Never expose an unauthenticated Memcached port to the public internet. Memcached has no role in serving HTTP responses, and its data is disposable: WordPress must continue to work when an item expires or is evicted.

Requests that must bypass page cache

Bypassing is safer than guessing. Apply the rule at the page-cache owner, and keep the Nginx and Varnish policies equivalent if both are present.

  • Methods: bypass POST and any method that changes state. Cache GET and HEAD only when the response is public.
  • Authentication: bypass logged-in users and any request carrying a cookie that changes the page for one visitor.
  • Administration: bypass /wp-admin/, login, registration, and related AJAX or REST routes that return private data.
  • XML-RPC: bypass /xmlrpc.php because it is an API endpoint, not a public page.
  • Feeds and sitemaps: choose a freshness policy explicitly. They may be cacheable, but a long TTL can delay publication or updates.
  • Query strings: bypass when parameters alter content, authentication, sorting, or output. Strip only known tracking parameters, and do so consistently in every layer.
  • Recent commenters and password protection: treat comment_author_ and wp-postpass_ cookies as private unless you have designed a safe variation.

Test each bypass with two browser sessions: one anonymous and one authenticated. Verify that a personalized response is never delivered after an anonymous cache hit.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Make invalidation part of publishing

A page can be correctly cached and still be operationally wrong if it remains stale after an edit. Establish one purge workflow that WordPress can invoke after publishing, updating, deleting, or changing a menu, widget, taxonomy archive, or front page.

Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.
  1. Identify the changed URL and related archives: the home page, post or page URL, category and tag archives, author archives, feeds, and any sitemap whose content changed.
  2. Send an authenticated purge, ban, or cache-delete request to the page-cache owner. Never expose a purge endpoint without authentication and network restrictions.
  3. Remove or expire the corresponding object-cache keys when application data changed. Memcached entries are often allowed to expire naturally, but explicit invalidation reduces the window of inconsistency.
  4. Request the public URL with a cache-status header and confirm a MISS followed by a HIT containing the new content.
  5. Record purge failures and retry them. A successful WordPress save is not proof that a reverse proxy was purged.

If you operate both Nginx FastCGI cache and Varnish, the same publication event must invalidate both stores. Otherwise one layer can continue to serve an older page after the other has been purged.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Headers, freshness and stale content

Separate browser caching from server-side caching. A browser’s Cache-Control header does not purge Varnish or Nginx, and purging a server cache does not remove an object already stored in a visitor’s browser. Use versioned asset filenames for static files and a deliberate policy for HTML.

Stale serving can preserve availability during a short origin failure, but it must have a bounded grace period and a way to refresh the object. Do not serve stale private responses. Check that upstream Set-Cookie, private, no-cache, and no-store directives prevent storage where appropriate.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Measure the stack instead of assuming it is faster

Collect measurements before and after each layer. Useful signals include:

  • Page-cache HIT, MISS, BYPASS, and expired-object counts.
  • Origin request rate, PHP-FPM queue depth, worker saturation, and response time.
  • Memcached gets, hits, misses, sets, evictions, item age, and memory usage.
  • Database query time and connection utilization on cache misses.
  • HTTP status codes, timeout rates, stale serves, and purge failures.
  • Separate timings for anonymous, logged-in, uncached, and cache-warmed requests.

Measure representative URLs after warming the cache and again after invalidation. A high hit rate is not automatically good if the cache key is wrong, content is stale, or misses overload PHP. Likewise, a lower hit rate may be correct for a site with many personalized pages.

Self-managed versus managed infrastructure

Consideration Self-managed Nginx, Varnish and Memcached Managed WordPress or infrastructure service
Operational effort You own installation, upgrades, TLS, firewalling, monitoring, backups, and incident response. The provider may operate the service and expose a smaller set of controls.
Version control You can pin and stage versions, but compatibility testing is your responsibility. Updates may be automated or scheduled by the provider.
Cache configuration Full access to Nginx rules, VCL, keys, headers, and purge hooks. Configuration varies; verify whether page caching, object caching, and custom purge APIs are available.
Support Internal expertise or a contracted administrator is required. Support may cover the platform but not arbitrary VCL or plugin behavior.
Best fit Teams that need custom routing, repeatable infrastructure, and operational ownership. Teams that value reduced maintenance and can work within documented cache policies.

Before choosing a managed service, confirm its geography, current pricing, PHP and WordPress support, Memcached availability, purge behavior, and access to cache-status logs. Feature names alone do not prove that a particular bypass or invalidation rule is supported.

Common failure modes and fixes

Pages never become cache hits

Inspect the response for Set-Cookie, private, or no-store. Check whether a plugin adds a cookie on every request, whether the request is being classified as logged-in, and whether query-string normalization creates a new key each time.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Users see another visitor’s content

Immediately bypass the affected URL, purge every page-cache layer, and inspect cookies and cache keys. Add an explicit bypass for the personalization cookie or endpoint before re-enabling caching.

Edits appear late

Trace the publish event through WordPress, the object cache, Nginx or Varnish, and the browser. A purge that reaches only one page-cache layer is incomplete; a long browser TTL can also preserve the old HTML.

Origin CPU rises after enabling cache

Check the actual HIT rate, not just whether the service is running. A fragmented query-string key, an unconditional cookie, or a bypass rule matching every request can turn the page cache into a pass-through. Check Memcached misses and database latency separately.

Varnish or Nginx returns intermittent errors

Review upstream timeouts, PHP-FPM saturation, stale-serving rules, and health checks. Temporarily disable grace or stale behavior only if it hides an application error you need to diagnose; restore a bounded availability policy after the cause is understood.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A safe rollout sequence

  1. Baseline anonymous and authenticated response times, origin load, and error rates with caching disabled.
  2. Enable static-file delivery and verify asset headers.
  3. Choose Nginx FastCGI cache or Varnish as the sole page-cache owner.
  4. Add method, cookie, endpoint, and query-string bypass rules, then test private and public sessions.
  5. Enable Memcached object caching and confirm hits, misses, and evictions.
  6. Implement authenticated purge hooks for posts, pages, archives, feeds, and menus.
  7. Warm representative URLs, observe cache status and origin load, and test a forced miss.
  8. Load-test or traffic-test the real workload, including publishing and logged-in activity, before increasing TTLs or memory limits.

The result should be a transparent system: anonymous public pages are served from one predictable page cache, dynamic requests reach WordPress, repeated object lookups avoid unnecessary database work, and every content change has a verified invalidation path.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.