{"id":220,"date":"2026-10-15T09:00:00","date_gmt":"2026-10-15T14:00:00","guid":{"rendered":"https:\/\/www.zee-way.com\/blog\/?p=220"},"modified":"2026-10-15T09:00:00","modified_gmt":"2026-10-15T14:00:00","slug":"cache-wordpress-behind-reverse-proxy-container","status":"publish","type":"post","link":"https:\/\/www.zee-way.com\/blog\/2026\/10\/cache-wordpress-behind-reverse-proxy-container\/","title":{"rendered":"How to Cache WordPress Behind a Reverse Proxy in a Container"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Running WordPress in a container can make deployments predictable, but containerization does not automatically make pages fast. Every uncached request may still start a PHP application process, query the database, render a theme, load plugins, and return a complete response. A reverse proxy adds a useful layer in front of that application: it can terminate HTTPS, serve static files, compress responses, and cache pages that do not need to be generated repeatedly.<\/p>\n\n\n<p class=\"wp-block-paragraph\">The safest design is selective caching rather than caching everything. Public articles, landing pages, and category archives are usually good candidates. Account pages, shopping carts, checkout screens, administrator URLs, previews, and personalized responses should normally bypass the cache. This guide explains a practical architecture for WordPress in a container without tying the approach to one orchestration platform.<\/p>\n\n\n<h2 class=\"wp-block-heading\">What a reverse proxy changes<\/h2>\n\n\n<p class=\"wp-block-paragraph\">A reverse proxy receives the visitor request before WordPress does. If a valid cached response exists, the proxy can return it immediately. If not, it forwards the request to the WordPress container, stores an eligible response, and serves that response to later visitors.<\/p>\n\n\n<p class=\"wp-block-paragraph\">This arrangement separates public traffic management from application execution. The proxy can handle TLS certificates, HTTP\/2 or HTTP\/3 support, redirects, connection limits, and basic security policies. WordPress remains responsible for content, plugins, themes, and administrative functions.<\/p>\n\n\n<ul class=\"wp-block-list\"><li><strong>Browser cache:<\/strong> stores files on an individual visitor&#8217;s device.<\/li><li><strong>Object cache:<\/strong> stores database results or application objects, commonly with Redis.<\/li><li><strong>Page cache:<\/strong> stores complete HTML responses for public requests.<\/li><li><strong>Reverse-proxy cache:<\/strong> places that page cache in a server-side proxy in front of WordPress.<\/li><\/ul>\n\n\n<p class=\"wp-block-paragraph\">These layers solve different problems. A reverse proxy can reduce PHP and database work, while Redis may reduce repeated database queries for requests that still need WordPress. They can be used together, but one should not assume that installing Redis automatically provides full-page caching.<\/p>\n\n\n<h2 class=\"wp-block-heading\">A practical container layout<\/h2>\n\n\n<p class=\"wp-block-paragraph\">A simple production layout contains three logical services: a public reverse proxy, a WordPress application, and a database. The proxy is the only service exposed to the internet. WordPress and the database communicate over a private container network.<\/p>\n\n\n<p class=\"wp-block-paragraph\">The proxy should forward requests to the application by an internal service name rather than a public IP. The database should not be published to the internet at all. Persistent volumes are needed for uploads, configuration, and database data; otherwise, replacing a container can remove files that the site needs.<\/p>\n\n\n<p class=\"wp-block-paragraph\">On a host running AlmaLinux, Rocky Linux, or Ubuntu, confirm that the proxy&#8217;s published ports are available and that the firewall allows only the intended services. A basic check on a Linux host can include:<\/p>\n\n\n<pre class=\"wp-block-code\"><code>sudo ss -tulpn\nsudo systemctl status firewalld<\/code><\/pre>\n\n\n<p class=\"wp-block-paragraph\">Use the firewall tooling appropriate to the distribution and your existing policy. Do not expose the database port merely because a container image documents it. Internal networking is part of the security model, not just a convenience.<\/p>\n\n\n<h2 class=\"wp-block-heading\">Define cache eligibility before writing rules<\/h2>\n\n\n<p class=\"wp-block-paragraph\">Cache rules should begin with exclusions. A request should usually bypass the page cache when it targets <code>\/wp-admin\/<\/code>, <code>\/wp-login.php<\/code>, a preview, a feed that must be current, or a page that depends on a logged-in visitor. Requests containing an administrator or session cookie should also be treated carefully.<\/p>\n\n\n<ul class=\"wp-block-list\"><li>Bypass requests using <code>POST<\/code>, <code>PUT<\/code>, or <code>DELETE<\/code> methods.<\/li><li>Do not cache responses that set a session or authentication cookie.<\/li><li>Exclude cart, checkout, account, search, and membership URLs where applicable.<\/li><li>Do not cache administrator and login paths.<\/li><li>Respect application headers such as <code>Cache-Control: private<\/code> or <code>no-store<\/code>.<\/li><li>Start with a short time-to-live, then increase it after testing.<\/li><\/ul>\n\n\n<p class=\"wp-block-paragraph\">The exact exclusions depend on the plugins installed. An online store, learning platform, forum, or membership site often has more dynamic routes than a brochure site. Review plugin documentation and test as an anonymous visitor and as a logged-in administrator.<\/p>\n\n\n<h2 class=\"wp-block-heading\">Preserve the original request information<\/h2>\n\n\n<p class=\"wp-block-paragraph\">WordPress needs to know whether the original visitor used HTTPS. If the proxy terminates TLS but fails to forward that information, WordPress may generate insecure links, create redirect loops, or report that the site URL is incorrect. Forward the host, client protocol, and client address using the proxy&#8217;s standard headers.<\/p>\n\n\n<p class=\"wp-block-paragraph\">WordPress can be configured to recognize a forwarded HTTPS request. The implementation varies by proxy and deployment method, so make the change in a controlled configuration file or environment variable rather than editing files blindly. Confirm that the application trusts only the proxy network; accepting arbitrary forwarded headers from the public internet can enable misleading request information.<\/p>\n\n\n<h2 class=\"wp-block-heading\">Static assets and compression<\/h2>\n\n\n<p class=\"wp-block-paragraph\">Images, stylesheets, JavaScript files, fonts, and uploaded media normally have longer lifetimes than HTML. Set cache headers for versioned assets so browsers can reuse them. If a theme or plugin changes a file without changing its URL, an excessively long browser lifetime can make visitors see an old version. Asset versioning or a purge process solves that problem.<\/p>\n\n\n<p class=\"wp-block-paragraph\">Enable compression at the proxy for text-based responses, but avoid compressing already compressed formats such as most JPEG, PNG, WebP, ZIP, and video files. HTTP\/2 and HTTP\/3 can improve connection behavior, but they do not replace good cache rules or efficient assets.<\/p>\n\n\n<h2 class=\"wp-block-heading\">Cache invalidation is part of publishing<\/h2>\n\n\n<p class=\"wp-block-paragraph\">A cached page is useful only while it is accurate. When an editor publishes or updates an article, the homepage, feeds, category pages, related content, and navigation may also become stale. A reliable setup therefore includes a purge mechanism, not just a cache lifetime.<\/p>\n\n\n<p class=\"wp-block-paragraph\">There are several practical approaches. A WordPress caching plugin may call the proxy purge endpoint after publishing. A deployment hook can purge known URLs. A proxy can use a short time-to-live when content changes frequently. For a small site, a manual purge button may be sufficient if the process is documented and tested.<\/p>\n\n\n<p class=\"wp-block-paragraph\">Never expose a purge endpoint publicly without authentication. Restrict it to localhost, an internal network, or a protected administrative request. A purge failure should be visible in logs; silently serving stale content can be more confusing than a clear warning.<\/p>\n\n\n<h2 class=\"wp-block-heading\">Cookies and personalized pages<\/h2>\n\n\n<p class=\"wp-block-paragraph\">Cookies are a common reason an apparently correct cache serves the wrong content. A visitor may have a login cookie, shopping cart cookie, language preference, or membership token. If the proxy ignores those cookies, it can deliver one visitor&#8217;s response to another visitor.<\/p>\n\n\n<p class=\"wp-block-paragraph\">The conservative approach is to bypass page caching whenever known authentication or session cookies are present. For public pages, remove irrelevant analytics cookies from the cache key rather than varying the cache for every visitor. Do this only after understanding the plugin behavior. A cache key with too many cookie variations can eliminate the benefit of caching.<\/p>\n\n\n<h2 class=\"wp-block-heading\">Object caching with Redis<\/h2>\n\n\n<p class=\"wp-block-paragraph\">Page caching does not eliminate every WordPress request. Administrators, logged-in users, APIs, uncached searches, and cache misses still reach PHP and the database. Redis can store frequently used objects and reduce repeated database work for those requests.<\/p>\n\n\n<p class=\"wp-block-paragraph\">Keep Redis on the private network and require authentication where supported. Configure a sensible memory policy and monitor evictions. Object caching should improve response consistency, but it cannot correct an inefficient plugin, an oversized query, or insufficient PHP workers by itself.<\/p>\n\n\n<h2 class=\"wp-block-heading\">Test the cache instead of assuming it works<\/h2>\n\n\n<p class=\"wp-block-paragraph\">Test with a private browser window and inspect response headers. Useful headers may show whether a response was a cache hit, miss, bypass, or revalidation. The names vary by proxy, so document the convention used by your configuration.<\/p>\n\n\n<pre class=\"wp-block-code\"><code>curl -I https:\/\/example.com\/\ncurl -I https:\/\/example.com\/wp-admin\/\ncurl -I -X POST https:\/\/example.com\/<\/code><\/pre>\n\n\n<p class=\"wp-block-paragraph\">Check the homepage while logged out, then log in and confirm that private content is not cached. Test a page with a form, a search URL, a mobile layout, and a page containing recently updated content. Also verify that a failed application container produces an intentional error rather than a stale private response.<\/p>\n\n\n<h2 class=\"wp-block-heading\">Monitor origin health and cache behavior<\/h2>\n\n\n<p class=\"wp-block-paragraph\">Track cache hit ratio, origin response time, PHP worker saturation, database load, memory use, disk space, and container restarts. A high hit ratio is not automatically good if visitors receive stale or incomplete pages. A lower ratio may be expected for a personalized site.<\/p>\n\n\n<p class=\"wp-block-paragraph\">Keep proxy and application logs separate when possible. Include a request identifier so a slow visitor request can be followed from the proxy to PHP and the database. Rotate logs before they consume the volume. Back up configuration and persistent content, not just the container image.<\/p>\n\n\n<h2 class=\"wp-block-heading\">Common reverse-proxy mistakes<\/h2>\n\n\n<ul class=\"wp-block-list\"><li><strong>Caching every response:<\/strong> this can expose private or transactional content.<\/li><li><strong>Forgetting HTTPS forwarding:<\/strong> this creates redirects, mixed content, or incorrect canonical URLs.<\/li><li><strong>Using a public database:<\/strong> the database should remain on a private network.<\/li><li><strong>Ignoring cache invalidation:<\/strong> visitors may see old navigation and outdated articles.<\/li><li><strong>Testing only as an administrator:<\/strong> administrator cookies often bypass the cache and hide public behavior.<\/li><li><strong>Skipping persistent volumes:<\/strong> replacing a container can remove uploads or configuration.<\/li><li><strong>Adding too many cache variations:<\/strong> cookies and query strings can fragment the cache.<\/li><\/ul>\n\n\n<h2 class=\"wp-block-heading\">When managed infrastructure is the better choice<\/h2>\n\n\n<p class=\"wp-block-paragraph\">A containerized reverse proxy is flexible, but it also creates operational responsibilities. Someone must patch the host, renew certificates, review logs, tune resources, test restores, and respond when a proxy or application container fails. The time required can outweigh the savings for a small business site.<\/p>\n\n\n<p class=\"wp-block-paragraph\">Zee-Way Hosting provides performance-focused <a href=\"https:\/\/www.zee-way.com\/hosting\/web-hosting\/\">web hosting<\/a> with NVMe SSD storage, PHP-FPM, OPcache, HTTP\/2 and HTTP\/3 support, and 24\u00d77 support. When more control is needed, a <a href=\"https:\/\/www.zee-way.com\/hosting\/cloud-vps\/\">Cloud VPS<\/a> provides an environment for custom proxy and caching architecture. The right choice depends on whether your priority is hands-on control or a simpler operating model.<\/p>\n\n\n<p class=\"wp-block-paragraph\">Whether you manage the stack yourself or use managed hosting, the principles remain the same: cache only public content, preserve request context, purge deliberately, protect private routes, and test from a visitor&#8217;s perspective. If you want a fast, supported foundation for WordPress, <a href=\"https:\/\/www.zee-way.com\/hosting\/web-hosting\/\">explore Zee-Way Hosting web hosting plans<\/a> and get your site running with a dependable performance stack.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to place WordPress behind a reverse proxy and add safe page caching when your site runs in a container. This guide covers architecture, cache rules, purging, cookies, HTTPS, troubleshooting, and production safeguards.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[8,6],"tags":[54,55,56,53,57,21],"class_list":["post-220","post","type-post","status-publish","format-standard","hentry","category-cloud-vps","category-web-hosting","tag-container-hosting","tag-page-caching","tag-redis","tag-reverse-proxy","tag-website-performance","tag-wordpress"],"jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p6hssc-3y","jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.zee-way.com\/blog\/wp-json\/wp\/v2\/posts\/220","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.zee-way.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zee-way.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zee-way.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zee-way.com\/blog\/wp-json\/wp\/v2\/comments?post=220"}],"version-history":[{"count":1,"href":"https:\/\/www.zee-way.com\/blog\/wp-json\/wp\/v2\/posts\/220\/revisions"}],"predecessor-version":[{"id":223,"href":"https:\/\/www.zee-way.com\/blog\/wp-json\/wp\/v2\/posts\/220\/revisions\/223"}],"wp:attachment":[{"href":"https:\/\/www.zee-way.com\/blog\/wp-json\/wp\/v2\/media?parent=220"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zee-way.com\/blog\/wp-json\/wp\/v2\/categories?post=220"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zee-way.com\/blog\/wp-json\/wp\/v2\/tags?post=220"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}