{"id":529780,"date":"2026-04-15T13:05:13","date_gmt":"2026-04-15T13:05:13","guid":{"rendered":"https:\/\/webkul.com\/blog\/?p=529780"},"modified":"2026-04-15T13:06:35","modified_gmt":"2026-04-15T13:06:35","slug":"nginx-fastcgi-cache-on-magento-2-with-php-fpm","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/nginx-fastcgi-cache-on-magento-2-with-php-fpm\/","title":{"rendered":"Nginx FastCGI Cache on Magento 2 with PHP-FPM"},"content":{"rendered":"\n<p>Configuring&nbsp;<strong>Nginx FastCGI Cache on Magento 2<\/strong>&nbsp;is one of the most effective ways to improve your store&#8217;s page speed and reduce server load. This guide covers the complete&nbsp;<strong>Nginx FastCGI Cache Magento 2<\/strong>&nbsp;setup with&nbsp;<strong>PHP-FPM<\/strong>&nbsp;\u2014 no additional software or reverse proxy required. FastCGI cache is built directly into Nginx and stores the HTML output generated by PHP, serving repeat requests instantly without invoking PHP or querying the database.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">Without Nginx FastCGI Cache\nBrowser \u2192 Nginx \u2192 PHP-FPM \u2192 Magento 2 \u2192 Database\nevery request runs PHP and hits the database \u2013 slow under load\n\nWith Nginx FastCGI Cache (HIT)\nBrowser \u2192 Nginx \u2192 FastCGI Cache \u2192 Response\nzero PHP, zero database \u2013 instant response for every guest visitor<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<p>Before setting up&nbsp;<strong>Nginx FastCGI Cache on Magento 2<\/strong>, ensure the following are in place on your server:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Ubuntu 20.04 \/ 22.04 \/ 24.04<\/li>\n\n\n\n<li>Nginx 1.18 or higher<\/li>\n\n\n\n<li>PHP 8.1 \/ 8.2 \/ 8.3 \/ 8.4 with PHP-FPM installed<\/li>\n\n\n\n<li>Magento 2.4.x installed and running<\/li>\n\n\n\n<li>Root or sudo access to the server<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Configure PHP-FPM Pool<\/h2>\n\n\n\n<p>PHP-FPM runs as a separate process that Nginx communicates with. First, install PHP-FPM with all extensions required by Magento 2:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">sudo apt update\nsudo apt install php8.3-fpm php8.3-mysql php8.3-xml php8.3-curl \\\n    php8.3-gd php8.3-mbstring php8.3-intl php8.3-bcmath \\\n    php8.3-soap php8.3-zip php8.3-xsl -y<\/pre>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Create a dedicated Magento PHP-FPM pool configuration:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">sudo nano \/etc\/php\/8.3\/fpm\/pool.d\/magento.conf<\/pre>\n\n\n\n<div style=\"height:12px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"EnlighterJSRAW\">&#091;magento]\nuser  = www-data\ngroup = www-data\n\n; TCP socket \u2014 matches the Nginx upstream directive\nlisten = 127.0.0.1:9000\n\npm                   = dynamic\npm.max_children      = 20\npm.start_servers     = 5\npm.min_spare_servers = 3\npm.max_spare_servers = 10\npm.max_requests      = 500\n\nphp_admin_value&#091;memory_limit]        = 756M\nphp_admin_value&#091;max_execution_time]  = 600\nphp_admin_value&#091;upload_max_filesize] = 64M\nphp_admin_value&#091;post_max_size]       = 64M\nphp_admin_flag&#091;log_errors]           = on\n\n; OPcache \u2014 strongly recommended for Magento 2 performance\nphp_admin_value&#091;opcache.memory_consumption]    = 512\nphp_admin_value&#091;opcache.max_accelerated_files] = 60000\n\n; Sessions\nphp_value&#091;session.save_handler] = files\nphp_value&#091;session.save_path]    = \/var\/www\/html\/magento\/var\/session<\/pre>\n\n\n\n<p>Enable and start PHP-FPM:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">sudo systemctl enable php8.3-fpm\nsudo systemctl start php8.3-fpm<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Configure Nginx FastCGI Cache Zone<\/h2>\n\n\n\n<p>The&nbsp;<strong>Nginx FastCGI Cache<\/strong>&nbsp;zone is defined inside the&nbsp;<code>http { }<\/code>&nbsp;block of&nbsp;<code>\/etc\/nginx\/nginx.conf<\/code>. This allocates shared memory for cache keys and sets the disk path where cached responses are stored.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">sudo nano \/etc\/nginx\/nginx.conf<\/pre>\n\n\n\n<p>Add the following inside the&nbsp;<code>http { }<\/code>&nbsp;block:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\"># \u2500\u2500 Nginx FastCGI Cache Zone for Magento 2 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n# keys_zone=magento_cache:256m  \u2192 256MB RAM for cache index\n# inactive=1d                   \u2192 remove cache unused for 1 day\n# max_size=10g                  \u2192 max 10GB disk cache\nfastcgi_cache_path \/var\/cache\/nginx\/magento_fastcgi_cache\n                   levels=1:2\n                   keys_zone=magento_cache:256m\n                   inactive=1d\n                   max_size=10g;\n\nfastcgi_cache_key &quot;$scheme$request_method$host$request_uri&quot;;\nfastcgi_cache_use_stale error timeout invalid_header http_500;\nfastcgi_ignore_headers  Cache-Control Expires Set-Cookie;\n\n; Buffer sizes \u2014 required for Magento 2 large response headers\nfastcgi_buffers         16 16k;\nfastcgi_buffer_size     32k;\nproxy_buffer_size       128k;\nproxy_buffers           4 256k;\nproxy_busy_buffers_size 256k;<\/pre>\n\n\n\n<p>Create the cache directory and set permissions:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">sudo mkdir -p \/var\/cache\/nginx\/magento_fastcgi_cache\nsudo chown -R www-data:www-data \/var\/cache\/nginx<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Configure Magento 2 Nginx Server Block<\/h2>\n\n\n\n<p>Create the Nginx server block for Magento 2. This file defines the&nbsp;<strong>FastCGI cache bypass rules<\/strong>, static file handling, and the PHP-FPM upstream connection.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">sudo nano \/etc\/nginx\/conf.d\/magento.conf<\/pre>\n\n\n\n<div style=\"height:11px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"EnlighterJSRAW\">upstream fastcgi_backend {\n    server 127.0.0.1:9000;\n    keepalive 32;\n}\n\nserver {\n    listen 80;\n    server_name yourdomain.com;\n\n    set $MAGE_ROOT \/var\/www\/html\/magento;\n    root $MAGE_ROOT\/pub;\n    index index.php;\n    autoindex off;\n    charset UTF-8;\n\n    # \u2500\u2500 FastCGI Cache Bypass Rules \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n    set $no_cache 0;\n\n    # Never cache POST requests\n    if ($request_method = POST)  { set $no_cache 1; }\n\n    # Never cache URLs with query strings\n    if ($query_string != &quot;&quot;)     { set $no_cache 1; }\n\n    # Never cache admin, checkout, cart, account, or API pages\n    if ($request_uri ~* &quot;\/(admin|adminhtml|checkout|cart|account|rest|graphql)&quot;) {\n        set $no_cache 1;\n    }\n\n    # Never cache requests from logged-in users\n    if ($http_cookie ~* &quot;PHPSESSID|admin_user|customer_logged_in|adminhtml&quot;) {\n        set $no_cache 1;\n    }\n\n    # \u2500\u2500 Security Headers \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n    add_header X-Frame-Options        &quot;SAMEORIGIN&quot;;\n    add_header X-XSS-Protection       &quot;1; mode=block&quot;;\n    add_header X-Content-Type-Options &quot;nosniff&quot;;\n\n    # \u2500\u2500 Static Files \u2014 served by Nginx directly (no PHP needed) \u2500\u2500\u2500\u2500\u2500\u2500\n    location \/static\/ {\n        expires max;\n        add_header Cache-Control &quot;public&quot;;\n        location ~ ^\/static\/version\\d*\/ {\n            rewrite ^\/static\/version\\d*\/(.*)$ \/static\/$1 last;\n        }\n        if (!-f $request_filename) {\n            rewrite ^\/static\/(version\\d*\/)?(.*)$ \/static.php?resource=$2 last;\n        }\n    }\n\n    location \/media\/ {\n        try_files $uri $uri\/ \/get.php$is_args$args;\n    }\n\n    # \u2500\u2500 PHP-FPM with Nginx FastCGI Cache \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n    location ~ ^\/(index|get|static|errors\/report|errors\/404|errors\/503|print)\\.php$ {\n        try_files $uri =404;\n\n        fastcgi_pass            fastcgi_backend;\n        fastcgi_index           index.php;\n        fastcgi_param           SCRIPT_FILENAME $document_root$fastcgi_script_name;\n        fastcgi_param           PHP_VALUE &quot;memory_limit=756M \\n max_execution_time=600&quot;;\n        fastcgi_read_timeout    600s;\n        fastcgi_connect_timeout 600s;\n        include                 fastcgi_params;\n\n        # Nginx FastCGI Cache directives\n        fastcgi_cache           magento_cache;\n        fastcgi_cache_valid 200 301 302  1h;   # cache hits for 1 hour\n        fastcgi_cache_valid 404          1m;   # cache 404s for 1 minute\n        fastcgi_cache_bypass    $no_cache;\n        fastcgi_no_cache        $no_cache;\n\n        # Shows HIT \/ MISS \/ BYPASS in response headers\n        add_header X-FastCGI-Cache $upstream_cache_status;\n    }\n\n    # \u2500\u2500 Magento 2 Front Controller \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n    location \/ {\n        try_files $uri $uri\/ \/index.php$is_args$args;\n    }\n\n    # \u2500\u2500 Deny Sensitive Files \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n    location ~* (\\.php$|\\.htaccess$|\\.git) { deny all; }\n    location ~ \/\\.                          { deny all; }\n}<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Set File Permissions<\/h2>\n\n\n\n<p>Correct file permissions allow Magento 2 to write cache, session, and generated files without errors:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\"># Set ownership\nsudo chown -R www-data:www-data \/var\/www\/html\/magento\n\n# Magento 2 writable directories\nsudo chmod -R 775 \/var\/www\/html\/magento\/var \\\n                  \/var\/www\/html\/magento\/generated \\\n                  \/var\/www\/html\/magento\/pub\/static \\\n                  \/var\/www\/html\/magento\/pub\/media \\\n                  \/var\/www\/html\/magento\/app\/etc\n\n# Make Magento CLI executable\nsudo chmod +x \/var\/www\/html\/magento\/bin\/magento<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Test the Configuration<\/h2>\n\n\n\n<h4 class=\"wp-block-heading\">Validate and Restart Services<\/h4>\n\n\n\n<pre class=\"EnlighterJSRAW\">sudo nginx -t\nsudo systemctl restart nginx\nsudo systemctl restart php8.3-fpm<\/pre>\n\n\n\n<p>A successful validation shows:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">nginx: configuration file \/etc\/nginx\/nginx.conf test is successful<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Verify Nginx FastCGI Cache is Working<\/h4>\n\n\n\n<p>Use&nbsp;<code>curl<\/code>&nbsp;to check the&nbsp;<code>X-FastCGI-Cache<\/code>&nbsp;response header:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\"># First request \u2014 cache is empty\ncurl -I http:\/\/yourdomain.com | grep X-FastCGI-Cache\n# X-FastCGI-Cache: MISS\n\n# Second request \u2014 served from Nginx FastCGI Cache\ncurl -I http:\/\/yourdomain.com | grep X-FastCGI-Cache\n# X-FastCGI-Cache: HIT \u26a1<\/pre>\n\n\n\n<p><strong>Note:<\/strong>&nbsp;<code>X-FastCGI-Cache: HIT<\/code>&nbsp;confirms that&nbsp;<strong>Nginx FastCGI Cache on Magento 2<\/strong>&nbsp;is working correctly \u2014 PHP-FPM and the database were not involved in serving the response.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Confirm Cache Files on Disk<\/h4>\n\n\n\n<pre class=\"EnlighterJSRAW\">ls -la \/var\/cache\/nginx\/magento_fastcgi_cache\/<\/pre>\n\n\n\n<p>Each file in this directory represents one cached Magento 2 page response stored on disk.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"s6\">Flush the Nginx FastCGI Cache<\/h2>\n\n\n\n<p>There are several ways to flush the&nbsp;<strong>Nginx FastCGI Cache<\/strong>&nbsp;on your Magento 2 store.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Full Flush \u2014 Delete All Cache Files<\/h4>\n\n\n\n<pre class=\"EnlighterJSRAW\">sudo rm -rf \/var\/cache\/nginx\/magento_fastcgi_cache\/*<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Flush Magento 2 + Nginx FastCGI Cache Together<\/h4>\n\n\n\n<pre class=\"EnlighterJSRAW\">php \/var\/www\/html\/magento\/bin\/magento cache:flush\nsudo rm -rf \/var\/cache\/nginx\/magento_fastcgi_cache\/*<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Reusable Flush Script<\/h4>\n\n\n\n<p>Save as&nbsp;<code>flush-cache.sh<\/code>&nbsp;and run it after every deployment:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">#!\/bin\/bash\necho &quot;Flushing Magento 2 cache...&quot;\nphp \/var\/www\/html\/magento\/bin\/magento cache:flush\n\necho &quot;Flushing Nginx FastCGI Cache...&quot;\nsudo rm -rf \/var\/cache\/nginx\/magento_fastcgi_cache\/*\n\necho &quot;\u2705 All caches flushed successfully!&quot;<\/pre>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"EnlighterJSRAW\">chmod +x flush-cache.sh\n.\/flush-cache.sh<\/pre>\n\n\n\n<p><strong>Important:<\/strong>&nbsp;Always flush both the Magento 2 cache and the Nginx FastCGI Cache after deploying code changes, running&nbsp;<code>setup:upgrade<\/code>, or deploying static content. Stale cache can cause your visitors to see outdated pages.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Nginx FastCGI Cache Status Reference<\/h2>\n\n\n\n<p>Every Nginx response includes an&nbsp;<code>X-FastCGI-Cache<\/code>&nbsp;header. Here is what each status value means for your Magento 2 store:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th class=\"has-text-align-left\" data-align=\"left\">Status<\/th><th class=\"has-text-align-left\" data-align=\"left\">Meaning<\/th><th class=\"has-text-align-left\" data-align=\"left\">PHP Called?<\/th><th class=\"has-text-align-left\" data-align=\"left\">DB Called?<\/th><\/tr><\/thead><tbody><tr><td><strong>HIT<\/strong><\/td><td>Served directly from Nginx FastCGI Cache \u26a1<\/td><td>\u274c No<\/td><td>\u274c No<\/td><\/tr><tr><td><strong>MISS<\/strong><\/td><td>Cache was empty \u2014 PHP processed and stored the response<\/td><td>\u2705 Yes<\/td><td>\u2705 Yes<\/td><\/tr><tr><td><strong>BYPASS<\/strong><\/td><td>Cache skipped \u2014 admin, checkout, cart, or logged-in user<\/td><td>\u2705 Yes<\/td><td>\u2705 Yes<\/td><\/tr><tr><td><strong>EXPIRED<\/strong><\/td><td>Cached entry expired and is being refreshed by PHP-FPM<\/td><td>\u2705 Yes<\/td><td>\u2705 Yes<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">What Nginx FastCGI Cache Serves on Magento 2<\/h2>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>Homepage<\/td><td><strong>HIT<\/strong><\/td><td>Guest visitor, no session cookie<\/td><\/tr><tr><td>Category pages<\/td><td><strong>HIT<\/strong><\/td><td>Guest visitor, no session cookie<\/td><\/tr><tr><td>Product pages<\/td><td><strong>HIT<\/strong><\/td><td>Guest visitor, no session cookie<\/td><\/tr><tr><td>CMS pages<\/td><td><strong>HIT<\/strong><\/td><td>Guest visitor, no session cookie<\/td><\/tr><tr><td>Admin panel<\/td><td><strong>BYPASS<\/strong><\/td><td>URL rule \u2014 \/admin<\/td><\/tr><tr><td>Checkout \/ Cart<\/td><td><strong>BYPASS<\/strong><\/td><td>URL rule \u2014 \/checkout<\/td><\/tr><tr><td>Customer account<\/td><td><strong>BYPASS<\/strong><\/td><td>Session cookie detected<\/td><\/tr><tr><td>REST API \/ GraphQL<\/td><td><strong>BYPASS<\/strong><\/td><td>URL rule \u2014 \/rest, \/graphql<\/td><\/tr><\/tbody><\/table><\/figure>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>Configuring&nbsp;<strong>Nginx FastCGI Cache on Magento 2<\/strong>&nbsp;with PHP-FPM is one of the simplest and most impactful performance improvements for any Magento 2 store. The setup requires no additional software \u2014 FastCGI cache is built directly into Nginx \u2014 and dramatically reduces server load and response times under real traffic.<\/p>\n\n\n\n<p>With&nbsp;<strong>Nginx FastCGI Cache<\/strong>&nbsp;in place, guest-facing pages such as the homepage, category pages, and product pages are served with zero PHP execution and zero database queries. At the same time, bypass rules ensure that the admin panel, checkout, cart, and logged-in customer sessions are always processed fresh by PHP-FPM, maintaining full Magento 2 functionality.<\/p>\n\n\n\n<p>For further Magento 2 performance improvements, consider combining Nginx FastCGI Cache with&nbsp;<strong>Redis<\/strong>&nbsp;for session and cache storage, and&nbsp;<strong>OpenSearch<\/strong>&nbsp;for catalog search.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Configuring&nbsp;Nginx FastCGI Cache on Magento 2&nbsp;is one of the most effective ways to improve your store&#8217;s page speed and reduce server load. This guide covers the complete&nbsp;Nginx FastCGI Cache Magento 2&nbsp;setup with&nbsp;PHP-FPM&nbsp;\u2014 no additional software or reverse proxy required. FastCGI cache is built directly into Nginx and stores the HTML output generated by PHP, serving <a href=\"https:\/\/webkul.com\/blog\/nginx-fastcgi-cache-on-magento-2-with-php-fpm\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":522,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"[]"},"categories":[1],"tags":[],"class_list":["post-529780","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Nginx FastCGI Cache on Magento 2 with PHP-FPM - Webkul Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/nginx-fastcgi-cache-on-magento-2-with-php-fpm\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Nginx FastCGI Cache on Magento 2 with PHP-FPM - Webkul Blog\" \/>\n<meta property=\"og:description\" content=\"Configuring&nbsp;Nginx FastCGI Cache on Magento 2&nbsp;is one of the most effective ways to improve your store&#8217;s page speed and reduce server load. This guide covers the complete&nbsp;Nginx FastCGI Cache Magento 2&nbsp;setup with&nbsp;PHP-FPM&nbsp;\u2014 no additional software or reverse proxy required. FastCGI cache is built directly into Nginx and stores the HTML output generated by PHP, serving [...]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/nginx-fastcgi-cache-on-magento-2-with-php-fpm\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2026-04-15T13:05:13+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-04-15T13:06:35+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-og.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Neeraj\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Neeraj\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/nginx-fastcgi-cache-on-magento-2-with-php-fpm\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/nginx-fastcgi-cache-on-magento-2-with-php-fpm\/\"},\"author\":{\"name\":\"Neeraj\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/9073535bedd2c836bc38e64c4403a974\"},\"headline\":\"Nginx FastCGI Cache on Magento 2 with PHP-FPM\",\"datePublished\":\"2026-04-15T13:05:13+00:00\",\"dateModified\":\"2026-04-15T13:06:35+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/nginx-fastcgi-cache-on-magento-2-with-php-fpm\/\"},\"wordCount\":672,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/nginx-fastcgi-cache-on-magento-2-with-php-fpm\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/nginx-fastcgi-cache-on-magento-2-with-php-fpm\/\",\"url\":\"https:\/\/webkul.com\/blog\/nginx-fastcgi-cache-on-magento-2-with-php-fpm\/\",\"name\":\"Nginx FastCGI Cache on Magento 2 with PHP-FPM - Webkul Blog\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"datePublished\":\"2026-04-15T13:05:13+00:00\",\"dateModified\":\"2026-04-15T13:06:35+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/nginx-fastcgi-cache-on-magento-2-with-php-fpm\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/nginx-fastcgi-cache-on-magento-2-with-php-fpm\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/nginx-fastcgi-cache-on-magento-2-with-php-fpm\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Nginx FastCGI Cache on Magento 2 with PHP-FPM\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/9073535bedd2c836bc38e64c4403a974\",\"name\":\"Neeraj\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/363737617997d7473ba2e8202fac23d142482c1e143db3bdaba4b68c30ac54a6?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/363737617997d7473ba2e8202fac23d142482c1e143db3bdaba4b68c30ac54a6?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Neeraj\"},\"url\":\"https:\/\/webkul.com\/blog\/author\/neeraj-mg853\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Nginx FastCGI Cache on Magento 2 with PHP-FPM - Webkul Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/webkul.com\/blog\/nginx-fastcgi-cache-on-magento-2-with-php-fpm\/","og_locale":"en_US","og_type":"article","og_title":"Nginx FastCGI Cache on Magento 2 with PHP-FPM - Webkul Blog","og_description":"Configuring&nbsp;Nginx FastCGI Cache on Magento 2&nbsp;is one of the most effective ways to improve your store&#8217;s page speed and reduce server load. This guide covers the complete&nbsp;Nginx FastCGI Cache Magento 2&nbsp;setup with&nbsp;PHP-FPM&nbsp;\u2014 no additional software or reverse proxy required. FastCGI cache is built directly into Nginx and stores the HTML output generated by PHP, serving [...]","og_url":"https:\/\/webkul.com\/blog\/nginx-fastcgi-cache-on-magento-2-with-php-fpm\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2026-04-15T13:05:13+00:00","article_modified_time":"2026-04-15T13:06:35+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-og.png","type":"image\/png"}],"author":"Neeraj","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Neeraj","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/nginx-fastcgi-cache-on-magento-2-with-php-fpm\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/nginx-fastcgi-cache-on-magento-2-with-php-fpm\/"},"author":{"name":"Neeraj","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/9073535bedd2c836bc38e64c4403a974"},"headline":"Nginx FastCGI Cache on Magento 2 with PHP-FPM","datePublished":"2026-04-15T13:05:13+00:00","dateModified":"2026-04-15T13:06:35+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/nginx-fastcgi-cache-on-magento-2-with-php-fpm\/"},"wordCount":672,"commentCount":0,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/nginx-fastcgi-cache-on-magento-2-with-php-fpm\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/nginx-fastcgi-cache-on-magento-2-with-php-fpm\/","url":"https:\/\/webkul.com\/blog\/nginx-fastcgi-cache-on-magento-2-with-php-fpm\/","name":"Nginx FastCGI Cache on Magento 2 with PHP-FPM - Webkul Blog","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"datePublished":"2026-04-15T13:05:13+00:00","dateModified":"2026-04-15T13:06:35+00:00","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/nginx-fastcgi-cache-on-magento-2-with-php-fpm\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/nginx-fastcgi-cache-on-magento-2-with-php-fpm\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/nginx-fastcgi-cache-on-magento-2-with-php-fpm\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Nginx FastCGI Cache on Magento 2 with PHP-FPM"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/9073535bedd2c836bc38e64c4403a974","name":"Neeraj","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/363737617997d7473ba2e8202fac23d142482c1e143db3bdaba4b68c30ac54a6?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/363737617997d7473ba2e8202fac23d142482c1e143db3bdaba4b68c30ac54a6?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Neeraj"},"url":"https:\/\/webkul.com\/blog\/author\/neeraj-mg853\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/529780","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/522"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=529780"}],"version-history":[{"count":38,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/529780\/revisions"}],"predecessor-version":[{"id":535350,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/529780\/revisions\/535350"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=529780"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=529780"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=529780"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}