{"id":871,"date":"2026-08-12T23:38:56","date_gmt":"2026-08-12T23:38:56","guid":{"rendered":"https:\/\/virtualserversvps.com\/blog\/?p=871"},"modified":"2026-08-12T23:38:56","modified_gmt":"2026-08-12T23:38:56","slug":"wordpress-caching-layers-vps","status":"publish","type":"post","link":"https:\/\/virtualserversvps.com\/blog\/wordpress-caching-layers-vps\/","title":{"rendered":"WordPress Caching Layers on a VPS: Page Cache, Object Cache, and CDN, Explained"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Hosting WordPress on a VPS gives you full control &mdash; and full responsibility for performance. A stock WordPress install runs dozens of PHP and database queries per page view, and on a small VPS that is a recipe for slow TTFB and CPU spikes. The fix is not one cache but a stack of them. This guide explains the four caching layers that matter on a VPS &mdash; OPcache, object cache, page cache, and CDN &mdash; in the order you should implement them, with the exact settings and commands for each.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Layer 1: OPcache (PHP Bytecode Cache)<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Every PHP request recompiles your theme and plugin files unless OPcache is enabled. On PHP 8.x it ships built in; you just need to size it. In <code>php.ini<\/code>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>opcache.enable=1<\/code> &mdash; turn it on<\/li>\n<li><code>opcache.memory_consumption=128<\/code> &mdash; enough for a typical plugin-heavy install<\/li>\n<li><code>opcache.max_accelerated_files=10000<\/code> &mdash; covers most themes plus plugins<\/li>\n<li><code>opcache.revalidate_freq=60<\/code> &mdash; check files for changes at most once a minute<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Verify with <code>php -i | grep opcache.enable<\/code> after restarting PHP-FPM. This layer alone typically cuts PHP execution time by 30&ndash;50% with zero downside.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Layer 2: Object Cache with Redis<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">WordPress stores options, transients, and fragments of repeated queries in the database by default. An object cache keeps those in memory. On Debian\/Ubuntu: <code>sudo apt install -y redis-server php-redis<\/code>, then install the Redis Object Cache plugin from the command line:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>wp plugin install redis-cache --activate &amp;&amp; wp redis enable<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Use the Query Monitor plugin afterwards to check the cache hit rate &mdash; healthy installs see 80&ndash;95% of queries served from Redis instead of MySQL. Allocate 64&ndash;128 MB of Redis memory on a 1&ndash;2 GB VPS; that is more than enough for most sites.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Layer 3: Page Cache (Nginx FastCGI Cache)<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Even with OPcache and Redis, every visit still runs PHP. A page cache stores the final HTML output so anonymous visitors never touch PHP at all. With nginx as your front server, FastCGI caching is the cleanest approach &mdash; no plugin needed. Key directives in your server block:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>fastcgi_cache_path \/var\/run\/nginx-cache levels=1:2 keys_zone=wpcache:10m inactive=60m;<\/code> &mdash; cache storage and zone<\/li>\n<li><code>fastcgi_cache wpcache;<\/code> &mdash; enable the cache for this server<\/li>\n<li><code>fastcgi_cache_valid 200 60m;<\/code> &mdash; cache successful pages for an hour<\/li>\n<li><code>fastcgi_cache_bypass $http_cookie;<\/code> &mdash; skip the cache for logged-in users (combined with a cookie check for comments\/cart)<\/li>\n<li><code>fastcgi_cache_purge<\/code> &mdash; purge the page when a post is updated (via the nginx-helper plugin or a custom rule)<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">With this in place, anonymous page views produce a TTFB of 20&ndash;80 ms instead of 300&ndash;800 ms, and your PHP-FPM workers stay free for logged-in traffic and admin requests. Just remember to purge the cache on post updates &mdash; a stale homepage is worse than a slow one.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Layer 4: CDN for Static Assets<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The final layer offloads JavaScript, CSS, images, and fonts to a CDN so your VPS only serves HTML and API traffic. Fingerprinted assets (with a hash in the filename) can be cached aggressively with <code>Cache-Control: public, max-age=31536000<\/code>. A CDN does not change server TTFB, but it dramatically improves first paint and time-to-interactive for visitors far from your data center, and it spares your VPS bandwidth and CPU on image-heavy pages.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Layer<\/th><th>Typical effect<\/th><th>Effort<\/th><\/tr><\/thead><tbody><tr><td>OPcache<\/td><td>&minus;30&ndash;50% PHP execution time<\/td><td>5 minutes<\/td><\/tr><tr><td>Object cache (Redis)<\/td><td>80&ndash;95% fewer DB queries<\/td><td>15 minutes<\/td><\/tr><tr><td>Page cache (FastCGI)<\/td><td>TTFB 20&ndash;80 ms for anonymous visits<\/td><td>30 minutes<\/td><\/tr><tr><td>CDN<\/td><td>Faster global load, less VPS bandwidth<\/td><td>1 hour<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">What Not to Cache<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Caching the wrong responses is worse than caching nothing. Never serve cached pages to logged-in users, active commenters, or anyone with a WooCommerce cart &mdash; personalized content must bypass the page cache entirely. The standard nginx approach keys on cookies: <code>fastcgi_cache_bypass $cookie_wordpress_logged_in;<\/code> combined with <code>fastcgi_cache_key \"$scheme$request_method$host$request_uri$cookie_wordpress_logged_in\";<\/code>. Admin pages under <code>\/wp-admin\/<\/code> should bypass as well. Set a short cache lifetime (5&ndash;15 minutes) for archive and taxonomy pages so recent posts appear quickly, and purge the cache whenever a post, page, or comment is published &mdash; the nginx-helper plugin wires WordPress hooks to purge endpoints automatically, and <code>wp cache flush<\/code> clears the object cache during deploys. Finally, exclude <code>sitemap.xml<\/code> and <code>robots.txt<\/code> from aggressive caching so search engines always see fresh metadata.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Putting It Together<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Implement the layers in order and verify each one before moving on: <code>curl -sI https:\/\/your-site\/ | grep -E 'HTTP|x-cache'<\/code> shows the page-cache header, Query Monitor confirms the Redis hit rate, and a before\/after run of <code>wrk -t2 -c20 -d30s https:\/\/your-site\/<\/code> quantifies the gain. All four layers fit comfortably on a 1 GB VPS &mdash; Redis at 64&ndash;128 MB, the nginx cache on disk, and OPcache inside PHP&#8217;s own memory. If you are choosing hardware for a WordPress project, the <a href=\"https:\/\/virtualserversvps.com\/#features\">VPS feature comparison at virtualserversvps.com<\/a> highlights plans with enough RAM and fast storage for a caching stack, and the <a href=\"https:\/\/virtualserversvps.com\/#providers\">provider comparison<\/a> helps you shortlist hosts with reliable NVMe tiers.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Start with OPcache and Redis today &mdash; they are the highest-impact, lowest-effort wins. <a href=\"https:\/\/virtualserversvps.com\/#providers\" rel=\"noreferrer noopener sponsored\">Find a VPS sized for a full WordPress caching stack and launch your site<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hosting WordPress on a VPS gives you full control &mdash; and full responsibility for performance. A stock WordPress install runs dozens of PHP and database queries per page view, and&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":2,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-871","post","type-post","status-publish","format-standard","hentry","category-vps-guides-tutorials"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.1 (Yoast SEO v26.1) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>WordPress Caching Layers on a VPS: Page Cache, Object Cache, and CDN, Explained - Virtual Servers VPS 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:\/\/virtualserversvps.com\/blog\/wordpress-caching-layers-vps\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"WordPress Caching Layers on a VPS: Page Cache, Object Cache, and CDN, Explained\" \/>\n<meta property=\"og:description\" content=\"WordPress Caching Layers on a VPS: Page Cache, Object Cache, and CDN, Explained\" \/>\n<meta property=\"og:url\" content=\"https:\/\/virtualserversvps.com\/blog\/wordpress-caching-layers-vps\/\" \/>\n<meta property=\"og:site_name\" content=\"Virtual Servers VPS Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-12T23:38:56+00:00\" \/>\n<meta name=\"author\" content=\"Virtual-Servers-Vps-Editor\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Virtual-Servers-Vps-Editor\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/wordpress-caching-layers-vps\/\",\"url\":\"https:\/\/virtualserversvps.com\/blog\/wordpress-caching-layers-vps\/\",\"name\":\"WordPress Caching Layers on a VPS: Page Cache, Object Cache, and CDN, Explained - Virtual Servers VPS Blog\",\"isPartOf\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#website\"},\"datePublished\":\"2026-08-12T23:38:56+00:00\",\"author\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0\"},\"breadcrumb\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/wordpress-caching-layers-vps\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/virtualserversvps.com\/blog\/wordpress-caching-layers-vps\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/wordpress-caching-layers-vps\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/virtualserversvps.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"WordPress Caching Layers on a VPS: Page Cache, Object Cache, and CDN, Explained\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#website\",\"url\":\"https:\/\/virtualserversvps.com\/blog\/\",\"name\":\"Virtual Servers VPS Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/virtualserversvps.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0\",\"name\":\"Virtual-Servers-Vps-Editor\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g\",\"caption\":\"Virtual-Servers-Vps-Editor\"},\"sameAs\":[\"https:\/\/virtualserversvps.com\/blog\"],\"url\":\"https:\/\/virtualserversvps.com\/blog\/author\/virtualserversvps\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"WordPress Caching Layers on a VPS: Page Cache, Object Cache, and CDN, Explained - Virtual Servers VPS 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:\/\/virtualserversvps.com\/blog\/wordpress-caching-layers-vps\/","og_locale":"en_US","og_type":"article","og_title":"WordPress Caching Layers on a VPS: Page Cache, Object Cache, and CDN, Explained","og_description":"WordPress Caching Layers on a VPS: Page Cache, Object Cache, and CDN, Explained","og_url":"https:\/\/virtualserversvps.com\/blog\/wordpress-caching-layers-vps\/","og_site_name":"Virtual Servers VPS Blog","article_published_time":"2026-08-12T23:38:56+00:00","author":"Virtual-Servers-Vps-Editor","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Virtual-Servers-Vps-Editor","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/virtualserversvps.com\/blog\/wordpress-caching-layers-vps\/","url":"https:\/\/virtualserversvps.com\/blog\/wordpress-caching-layers-vps\/","name":"WordPress Caching Layers on a VPS: Page Cache, Object Cache, and CDN, Explained - Virtual Servers VPS Blog","isPartOf":{"@id":"https:\/\/virtualserversvps.com\/blog\/#website"},"datePublished":"2026-08-12T23:38:56+00:00","author":{"@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0"},"breadcrumb":{"@id":"https:\/\/virtualserversvps.com\/blog\/wordpress-caching-layers-vps\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/virtualserversvps.com\/blog\/wordpress-caching-layers-vps\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/virtualserversvps.com\/blog\/wordpress-caching-layers-vps\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/virtualserversvps.com\/blog\/"},{"@type":"ListItem","position":2,"name":"WordPress Caching Layers on a VPS: Page Cache, Object Cache, and CDN, Explained"}]},{"@type":"WebSite","@id":"https:\/\/virtualserversvps.com\/blog\/#website","url":"https:\/\/virtualserversvps.com\/blog\/","name":"Virtual Servers VPS Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/virtualserversvps.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0","name":"Virtual-Servers-Vps-Editor","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g","caption":"Virtual-Servers-Vps-Editor"},"sameAs":["https:\/\/virtualserversvps.com\/blog"],"url":"https:\/\/virtualserversvps.com\/blog\/author\/virtualserversvps\/"}]}},"_links":{"self":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/871","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/comments?post=871"}],"version-history":[{"count":2,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/871\/revisions"}],"predecessor-version":[{"id":877,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/871\/revisions\/877"}],"wp:attachment":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/media?parent=871"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/categories?post=871"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/tags?post=871"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}