12 October 2026

NGINX Proxy Cache vs. FastCGI Cache: Same Engine, Different Locations. Which Should You Choose?

Proxy Cache and FastCGI Cache aren't rivals in terms of speed: they use the same engine as NGINX. The difference is where they are located in the architecture, and therefore what problems they solve.

NGINX Proxy Cache vs. FastCGI Cache

When talking about caching with NGINX, the question sooner or later comes up: which is better, Proxy Cache or FastCGI Cache ? You can find comparisons, benchmarks, and conflicting opinions online, often based on the idea that one is "faster" than the other. This is a poorly framed question. The two caches use the same engine, store data in the same way, and respond with the same speed. What differs is where they are located in the architecture and therefore what problems they are able to solve.

In this article, I explain what they are, how they're similar, where they really differ, and when one or the other is more convenient. I also look at how we use them in practice on the servers we manage, including the one that hosts this site.

Same engine, two different positions

NGINX has a single caching mechanism, which can be connected to different types of backends. The two most commonly used variants are:

  • la Proxy Cache it is used when NGINX works as a reverse proxy and forwards requests to another HTTP server: an Apache, a second NGINX, a Node.js or Java application, a Varnish, a server on another machine;
  • la Fast CGI Cache It is used when NGINX talks directly to the application interpreter through the FastCGI protocol, typically PHP-FPM for WordPress, WooCommerce, PrestaShop, Magento or Laravel.

In both cases, the principle is identical: the first time a page is requested, NGINX requests it from the backend, delivers it to the visitor, and stores a copy. Subsequent requests for the same page are served from that copy, without disturbing the backend, as long as the copy is valid.

Proxy Cache and FastCGI Cache Location in NGINX Architecture
The Proxy Cache sits in front of any HTTP server, the FastCGI Cache talks directly to PHP-FPM

Even the data storage method is the same. Pages are saved as files on disk, while the list of keys and information about each copy are stored in a memory area shared between NGINX processes. In practice, thanks to the operating system cache, the most requested pages remain in RAM and are served almost without touching the disk. The performance of a response served from the cache is therefore equivalent: in both cases, NGINX reads a ready copy.

The functions in common

The two caches also share all the features that matter in production:

  • rules on what to keep and for how long, based on the response code, headers sent by the backend or durations decided by the system administrator;
  • exclusions for authenticated users, shopping carts, reserved areas and requests other than simple reading;
  • racing protection: when a page expires and a hundred requests arrive at once, only one goes to the backend to regenerate it and the others wait, instead of all hitting PHP or the database at once;
  • expired copy serviceWhile the new version is being prepared, or if the backend temporarily fails, NGINX can continue serving the previous copy. This is one of the most valuable features, as it turns a slow or struggling backend into a responsive site.
  • background update, which regenerates the expired page without making the visitor wait.

There's also a common limitation, which is worth knowing about: the open source version of NGINX doesn't allow for targeted deletion of a single page . The purge feature is part of the commercial NGINX Plus subscription; the free version relies on third-party modules or designs the cache with short lifetimes. This is one of the reasons why, where precise invalidation is needed, we include Varnish in the chain.

Where is the real difference?

While the engine is the same, the difference lies in three practical aspects.

1. The number of steps

With FastCGI Cache, NGINX communicates directly with PHP-FPM: visitor request, NGINX, PHP. There are no intermediaries. With Proxy Cache, however, an additional step is required when dealing with a PHP application: NGINX forwards the request via HTTP to another web server, which in turn passes it on to PHP. This difference isn't noticeable on pages served from cache; on MISSes, there's a small additional cost, which is almost always negligible compared to the page generation time, but which doesn't provide any benefits on a single server.

2. What's behind it?

The FastCGI Cache only makes sense if there's a FastCGI process behind it. The Proxy Cache works in front of anything that speaks HTTP: another server, a containerized application, a service on another machine, an entire cluster. This makes it the natural tool for multi-tier architectures, edge nodes serving content from distant servers, and non-PHP applications.

3. Who decides the duration?

In both cases, the cache can honor the headers sent by the application or ignore them and follow the system administrator's rules. In practice, however, with FastCGI Cache, the configuration lives on the same server as the application, and whoever manages it knows the CMS; with Proxy Cache, it's often located on a separate level, perhaps managed by a different team, and it becomes crucial for the application to correctly communicate what can and cannot be stored.

When to Choose Proxy Cache or FastCGI Cache
The choice depends on the architecture, not the benchmark

When to choose the FastCGI Cache

FastCGI Cache is the simplest and most effective choice when:

  • there is a single server with NGINX and PHP-FPM, as in most WordPress sites and small e-commerce sites;
  • we want the shortest possible path between visitor and application, without additional services to maintain;
  • There are many public pages that are the same for all anonymous visitors, and personal pages are recognizable by a cookie.

It's also the quickest way to give a struggling site a break during a traffic spike: a few seconds of caching on public pages is enough to drastically reduce the number of busy PHP processes.

When to choose Proxy Cache

Proxy Cache is the right choice when:

  • behind NGINX there is not PHP-FPM but another HTTP server, an application in Node.js, Python or Java, or a service on another machine;
  • architecture is multi-level: an on-board NGINX that terminates HTTPS and secures the infrastructure, one or more internal layers, perhaps a Varnish;
  • You want to put a cache in front of an existing system without modifying it, for example an old Apache server that cannot be migrated immediately.

The microcache: a few seconds that save the server

A technique we often use, with both caches, is microcaching : storing pages for just a few seconds. It may seem pointless, but think of a page requested a hundred times a second during a campaign or a TV appearance. With a one-second cache, the backend generates it once a second instead of a hundred. The content effectively stays up-to-date, while the load drops dramatically.

It's the same logic we apply on our site. At the front, there's an NGINX that terminates HTTPS and maintains a microcache of public pages, with a copy for each type of compression requested by browsers. Behind it all is Varnish, which manages the actual cache with its own rules and the ability to invalidate pages, and only after that comes the server running PHP. The NGINX layer on top, in this scheme, is actually a proxy cache: it doesn't have PHP in front, it has another HTTP server.

The most common mistakes

Whichever cache you choose, the problems we see most often on the sites we manage are always the same:

  • cache keys too poor, which don't distinguish between different versions of the same page: desktop and mobile, languages, currencies, compression. The result is a visitor receiving the wrong version;
  • cached personal pagesCarts, customer areas, and usernames displayed in the header. It only takes a few minutes of incorrect configuration to show one customer another's information.
  • cookies that make everything non-storableBy default, NGINX doesn't cache responses that set a cookie, and many applications set one on every page even when it's not needed. The cache is there, but it's never used;
  • no racing protection: when a highly requested page expires, dozens of requests arrive at the backend at once and the server starts to struggle just when the cache should be protecting it;
  • no measure: Without observing how many requests are served from the cache and how many arrive at the backend, you don't know whether the cache is working or if it's just an additional cost.

And Varnish?

NGINX caches are excellent for simple load reduction. Varnish is superior when fine-grained control is required: complex rules written in a dedicated language, precise invalidation of individual pages or groups of pages, and elaborate management of variants and cookies. This isn't an exclusive alternative: in the architectures we manage, NGINX and Varnish caches often work together, each working where it performs best. We've discussed this, for example, in the articles on Joomla and Varnish and on Drupal and tag caches.

Conclusions

"Proxy Cache or FastCGI Cache?" isn't a race. The two caches are the same tool connected at two different points: FastCGI Cache shortens the path when NGINX and PHP are on the same server, while Proxy Cache allows you to place a cache in front of any backend and build multi-tier architectures. The choice depends on the architecture, not the benchmark. And in both cases, the difference between a useful cache and a useless, or dangerous, cache is made by the rules: what to store, for whom, for how much, and how to behave when the backend slows down.

If you want to understand which cache your project needs, or why the one you have doesn't seem to be working, with our NGINX support service we analyze the architecture and configure it custom, and on our Dedicated Servers we find it already ready and optimized.

Do you have doubts? Don't know where to start? Contact us!

We have all the answers to your questions to help you make the right choice.

Chat with us

Chat directly with our presales support.

0256569681

Contact us by phone during office hours 9:30 - 19:30

Contact us online

Open a request directly in the contact area.

DISCLAIMER, Legal Notes and Copyright. RedHat, Inc. holds the rights to Red Hat®, RHEL®, RedHat Linux®, and CentOS®; AlmaLinux™ is a trademark of the AlmaLinux OS Foundation; Rocky Linux® is a registered trademark of the Rocky Linux Foundation; SUSE® is a registered trademark of SUSE LLC; Canonical Ltd. holds the rights to Ubuntu®; Software in the Public Interest, Inc. holds the rights to Debian®; Linus Torvalds holds the rights to Linux®; FreeBSD® is a registered trademark of The FreeBSD Foundation; NetBSD® is a registered trademark of The NetBSD Foundation; OpenBSD® is a registered trademark of Theo de Raadt; Oracle Corporation holds the rights to Oracle®, MySQL®, MyRocks®, VirtualBox®, and ZFS®; Percona® is a registered trademark of Percona LLC; MariaDB® is a registered trademark of MariaDB Corporation Ab; PostgreSQL® is a registered trademark of PostgreSQL Global Development Group; SQLite® is a registered trademark of Hipp, Wyrick & Company, Inc.; KeyDB® is a registered trademark of EQ Alpha Technology Ltd.; Typesense® is a registered trademark of Typesense Inc.; REDIS® is a registered trademark of Redis Labs Ltd; F5 Networks, Inc. owns the rights to NGINX® and NGINX Plus®; Varnish® is a registered trademark of Varnish Software AB; HAProxy® is a registered trademark of HAProxy Technologies LLC; Traefik® is a registered trademark of Traefik Labs; Envoy® is a registered trademark of CNCF; Adobe Inc. owns the rights to Magento®; PrestaShop® is a registered trademark of PrestaShop SA; Shopware® is a registered trademark of Shopware AG; OpenCart® is a registered trademark of OpenCart Limited; Automattic Inc. holds the rights to WordPress®, WooCommerce®, and JetPack®; Open Source Matters, Inc. owns the rights to Joomla®; Dries Buytaert owns the rights to Drupal®; Shopify® is a registered trademark of Shopify Inc.; BigCommerce® is a registered trademark of BigCommerce Pty. Ltd.; TYPO3® is a registered trademark of the TYPO3 Association; Ghost® is a registered trademark of the Ghost Foundation; Amazon Web Services, Inc. owns the rights to AWS® and Amazon SES®; Google LLC owns the rights to Google Cloud™, Chrome™, and Google Kubernetes Engine™; Alibaba Cloud® is a registered trademark of Alibaba Group Holding Limited; DigitalOcean® is a registered trademark of DigitalOcean, LLC; Linode® is a registered trademark of Linode, LLC; Vultr® is a registered trademark of The Constant Company, LLC; Akamai® is a registered trademark of Akamai Technologies, Inc.; Fastly® is a registered trademark of Fastly, Inc.; Let's Encrypt® is a registered trademark of the Internet Security Research Group; Microsoft Corporation owns the rights to Microsoft®, Azure®, Windows®, Office®, and Internet Explorer®; Mozilla Foundation owns the rights to Firefox®; Apache® is a registered trademark of The Apache Software Foundation; Apache Tomcat® is a registered trademark of The Apache Software Foundation; PHP® is a registered trademark of the PHP Group; Docker® is a registered trademark of Docker, Inc.; Kubernetes® is a registered trademark of The Linux Foundation; OpenShift® is a registered trademark of Red Hat, Inc.; Podman® is a registered trademark of Red Hat, Inc.; Proxmox® is a registered trademark of Proxmox Server Solutions GmbH; VMware® is a registered trademark of Broadcom Inc.; CloudFlare® is a registered trademark of Cloudflare, Inc.; NETSCOUT® is a registered trademark of NETSCOUT Systems Inc.; ElasticSearch®, LogStash®, and Kibana® are registered trademarks of Elastic NV; Grafana® is a registered trademark of Grafana Labs; Prometheus® is a registered trademark of The Linux Foundation; Zabbix® is a registered trademark of Zabbix LLC; Datadog® is a registered trademark of Datadog, Inc.; Ceph® is a registered trademark of Red Hat, Inc.; MinIO® is a registered trademark of MinIO, Inc.; Mailgun® is a registered trademark of Mailgun Technologies, Inc.; SendGrid® is a registered trademark of Twilio Inc.; Postmark® is a registered trademark of ActiveCampaign, LLC; cPanel®, LLC owns the rights to cPanel®; Plesk® is a registered trademark of Plesk International GmbH; Hetzner® is a registered trademark of Hetzner Online GmbH; OVHcloud® is a registered trademark of OVH Groupe SAS; Contabo® is a registered trademark of Contabo GmbH; IONOS® is a registered trademark of IONOS SE; International Business Machines Corporation owns the rights to IBM® and IBM Cloud®; Terraform® is a registered trademark of HashiCorp, Inc.; Ansible® is a registered trademark of Red Hat, Inc.; cURL® is a registered trademark of Daniel Stenberg; Facebook®, Inc. owns the rights to Facebook®, Messenger® and Instagram®. This site is not affiliated with, sponsored by, or otherwise associated with any of the above-mentioned entities and does not represent any of these entities in any way. All rights to the brands and product names mentioned are the property of their respective copyright holders. All other trademarks mentioned are the property of their respective registrants. MANAGED SERVER® is a European registered trademark of MANAGED SERVER SRL, with registered office in Via Flavio Gioia, 6, 62012 Civitanova Marche (MC), Italy and operational headquarters in Via Enzo Ferrari, 9, 62012 Civitanova Marche (MC), Italy.

JUST A MOMENT !

Have you ever wondered if your hosting sucks?

Find out now if your hosting provider is hurting you with a slow website worthy of 1990! Instant results.

Close the CTA
Back to top