{"id":4307,"date":"2018-01-25T01:37:27","date_gmt":"2018-01-25T01:37:27","guid":{"rendered":"https:\/\/www.inmotionhosting.com\/support\/2018\/01\/25\/nginx-cache-management\/"},"modified":"2024-05-10T12:12:34","modified_gmt":"2024-05-10T16:12:34","slug":"nginx-cache-management","status":"publish","type":"post","link":"https:\/\/www.inmotionhosting.com\/support\/website\/nginx-cache-management\/","title":{"rendered":"NGINX Cache Management"},"content":{"rendered":"<p>In this article, we will explore the various NGINX cache configuration options, and tips on tweaking your site to get the best performance out of the WordPress Optimized Stack. This guide covers all of the most common parameters you can tune via the Cache Manager Plugin.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>The information in this tutorial applies to our hosting plans that use NGINX Caching which includes our WordPress Hosting plans and certain VPS configurations.<\/li><li>We also reference various settings pertaining to the Cache Manager Plugin for cPanel. Please see our tutorial on the <a href=\"https:\/\/www.inmotionhosting.com\/support\/website\/cache-manager-cpanel\/\">Cache Manager Plugin<\/a> for more information.<\/li><li>For an in-depth explanation of how NGINX and the rest of the stack work together, please check out our <a href=\"\/support\/product-guides\/wordpress-hosting\/the-wordpress-hosting-stack\/\">WordPress Hosting Stack<\/a> article.<\/li><\/ul>\n\n\n<div class=\"jumbotron\">\r\n<p>For the most secure WordPress site, you need secure hosting. That\u2019s why InMotion Hosting crafted <a href=\"https:\/\/www.inmotionhosting.com\/wordpress-hosting\">WordPress Hosting<\/a> with rigorous server-side security - so you can spend less time hardening your hosting and more time creating your website.<\/p>\r\n<p><a class=\"btn btn-primary btn-lg\" href=\"https:\/\/www.inmotionhosting.com\/wordpress-hosting\">WordPress Hosting Plans<\/a><\/p>\r\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Configuring Cache Parameters<\/h2>\n\n\n\n<p>The default cache parameters, configured via the Cache Manager Plugin, should work for most websites. However, in some cases, these values may need tweaking. For example, they may need to be adjusted to further improve performance for high-traffic websites or to allow caching to work correctly with certain eCommerce or dynamic content. We provide general usage suggestion and outline the major options that are tuneable below.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Cache Expiration<\/h2>\n\n\n\n<p>You can set page cache time via the <em>Default Cache Time<\/em> (<code>cache_time_default<\/code>) parameter. This parameter defines how long a page will remain valid after it has been cached by the server (by default, 4 hours). Once the age of the cached page has exceeded the expiration time, the server will fetch a new page from Apache or PHP, then cache the new result. In the event of a connection error or 500 error when attempting to fetch the updated page, NGINX will instead show the user the expired page from the cache. This allows your site to appear online, even if the back end is temporarily down or having problems.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img decoding=\"async\" width=\"423\" height=\"94\" src=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2020\/08\/nginx-cache-time-1.jpg\" class=\"optimized-lcp-image\" alt=\"\" loading=\"eager\" fetchpriority=\"high\" sizes=\"(max-width: 768px) 100vw, 768px\" srcset=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2020\/08\/nginx-cache-time-1.jpg 423w, https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2020\/08\/nginx-cache-time-1-300x67.jpg 300w\"><figcaption>NGINX Cache Refresh time setting<\/figcaption><\/figure><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Bypass URLs<\/h3>\n\n\n\n<p>Most websites have certain pages that should never be cached, such as login pages or checkout pages. You can exclude pages or URI patterns from caching under the <em>Bypass URLs<\/em> section (<code>cache_bypass_paths<\/code>) in the Cache Manager Plugin. The default configuration already contains some common patterns and will exclude <code>wp-login.php<\/code>, <code>wp-admin<\/code> as well as a few others. If you find a page is being cached, but should not be, then adding it to this list should solve the problem.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2020\/08\/nginx-cache-bypass-url.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"644\" height=\"581\" src=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2020\/08\/nginx-cache-bypass-url.jpg\" alt=\"Where to add NGINX Bypass URLs\" class=\"wp-image-58679\" srcset=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2020\/08\/nginx-cache-bypass-url.jpg 644w, https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2020\/08\/nginx-cache-bypass-url-300x271.jpg 300w\" sizes=\"auto, (min-width: 1360px) 876px, (min-width: 960px) calc(61.58vw + 51px), calc(100vw - 80px)\" \/><\/a><figcaption>NGINX Bypass URLs<\/figcaption><\/figure><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Static Content<\/h3>\n\n\n\n<p>Static content\u2014 such as images, Javascript, and stylesheets\u2014 typically do not change very often. Because of this, NGINX can quickly serve them when requested by visitors browsing your website. In the default configuration, NGINX will directly serve all static assets, rather than forwarding the request to Apache. This helps accelerate the requests, and prevents needlessly caching already static data. You can configure this setting via the <em>Accelerate Static Content<\/em> option (<code>accel_static_content<\/code>).<\/p>\n\n\n\n<p>Specific static content paths can also be defined from within the Cache Manager interface. This is typically not required, as NGINX will serve static content based on the file extension (such as <code>png<\/code>, <code>jpg<\/code>, <code>js<\/code>, etc.). This option is provided primarily to allow serving additional static assets or downloads that use an uncommon file extension or in combination with complex passthru rules. You can configure this setting via the <em>Static Content Path<\/em> option (<code>static_content_paths<\/code>).<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2020\/08\/NGINX-static-content-path.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"649\" height=\"163\" src=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2020\/08\/NGINX-static-content-path.jpg\" alt=\"Static content pathb\" class=\"wp-image-58680\" srcset=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2020\/08\/NGINX-static-content-path.jpg 649w, https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2020\/08\/NGINX-static-content-path-300x75.jpg 300w\" sizes=\"auto, (min-width: 1360px) 876px, (min-width: 960px) calc(61.58vw + 51px), calc(100vw - 80px)\" \/><\/a><figcaption>Static content path<\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Force Passthru<\/h3>\n\n\n\n<p>The default handling of static content can potentially cause problems on websites that generate dynamic images or other files normally considered static. A telltale sign of this problem is a <code>404 Not Found<\/code> error for dynamically generated content. In these cases, you can add the script or path to the <em>Force Passthru<\/em> list (<code>force_passthru<\/code>), found under the Advanced tab in the Cache Manager Plugin. For example, if your site generates dynamic thumbnails at <code>https:\/\/example.com\/thumbs\/thumb01.png<\/code>, then you would add <code>\/thumbs\/<\/code> to the <em>Force Passthru<\/em> list. When a URI matches a pattern in this list, it always passes through to Apache, and normal caching rules still apply. If you need to bypass the cache for a particular page, you should use the <em>Bypass URLs<\/em> setting instead.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2020\/08\/nginx-force-passthru.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"648\" height=\"144\" src=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2020\/08\/nginx-force-passthru.jpg\" alt=\"Force Passthru Path\" class=\"wp-image-58681\" srcset=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2020\/08\/nginx-force-passthru.jpg 648w, https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2020\/08\/nginx-force-passthru-300x67.jpg 300w\" sizes=\"auto, (min-width: 1360px) 876px, (min-width: 960px) calc(61.58vw + 51px), calc(100vw - 80px)\" \/><\/a><figcaption>Force Passthru Path<\/figcaption><\/figure><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Bypass Cookies<\/h3>\n\n\n\n<p>If you run a website that allows both anonymous and logged-in users to browse at the same time, you will likely still want to cache pages for anonymous users, but not for logged-in users. In most cases, you can accomplish this by using the <em>Bypass Cookies<\/em> list (<code>bypass_cookies<\/code>) in the Cache Manager Plugin. By default, the system will automatically add patterns matching the WordPress login cookie (<code>_logged_in_<\/code>) and the WooCommerce \u201citems in cart\u201d indicator (<code>items_in_cart<\/code>).<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2020\/08\/nginx-bypass-cookie.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"651\" height=\"276\" src=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2020\/08\/nginx-bypass-cookie.jpg\" alt=\"Bypass Cookies by matching specific strings\" class=\"wp-image-58682\" srcset=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2020\/08\/nginx-bypass-cookie.jpg 651w, https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2020\/08\/nginx-bypass-cookie-300x127.jpg 300w\" sizes=\"auto, (min-width: 1360px) 876px, (min-width: 960px) calc(61.58vw + 51px), calc(100vw - 80px)\" \/><\/a><figcaption>List of strings that will trigger a cache bypass<\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Cache-Control Headers<\/h3>\n\n\n\n<p>NGINX ignores cache control headers <code>Cache-Control<\/code> and <code>Expires<\/code> for the purposes of caching. This owes to the fact that most CMS\u2019s, including WordPress, will mark the page as uncacheable and add an expiration time in the past (to prevent caching). However, in most cases, the CMS can cache these pages without any problems, provided the page does not contain dynamically generated content that updates on every page load.<\/p>\n\n\n\n<p>If your website migrated from a platform that made effective use of these headers, you can re-enable their use by setting the <code>cache_honor_cc<\/code> and <code>cache_honor_expires<\/code> options for enabling <code>Cache-Control<\/code> and <code>Expires<\/code> headers, respectively. Please note that you cannot currently change these options from within the Cache Manager Plugin. Although this option may be added in the future, at the moment you can only change the option in the config files, located at <code>~\/.imh\/nginx<\/code>. Please reach out to our Support team if you would like assistance with changing these options. However, please note that most users will want to retain the default options for these settings. On the other hand, if you plan to write a custom application or plugin to manage caching, you should use the below-described <code>X-Accel-Expires<\/code> header (or a plugin that uses this method).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">X-Accel Headers<\/h3>\n\n\n\n<p>Sometimes, you may need more granular control over cache expiration times. In this case, NGINX allows the use of X-Accel headers. For this discussion, we will focus on the <code>X-Accel-Expires<\/code> header. This allows each page to return the expiration time, in seconds, with zero (<code>0<\/code>) meaning that the system should not cache the page. Some plugins, such as <a rel=\"noreferrer noopener\" href=\"https:\/\/wordpress.org\/plugins\/nginx-champuru\/\" target=\"_blank\">NGINX Cache Controller<\/a>, utilize the <code>X-Accel-Expires<\/code> header to explicitly set cache times for various page types.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Cache Management and Purging<\/h3>\n\n\n\n<p>To obtain the best performance, best practices typically call for setting a long cache time (4 hours, by default), then clearing pages from the cache after they have changed. Below are some examples of how to achieve this, depending upon your needs.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Automatic Expiration<\/h3>\n\n\n\n<p>Using a plugin, such as the <a href=\"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/plugins\/wordpress-nginx-helper-plugin\/\">NGINX Helper<\/a> plugin for WordPress, you can set pages to automatically expire after you make changes to the site (such as posting a new article, new comments, etc.). We recommend this plugin for all WordPress sites utilizing the WordPress Optimized Stack, as it automates cache management for most day-to-day tasks.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Purging the Entire Cache<\/h3>\n\n\n\n<p>When you make major changes to your site, such as underlying code changes, or major updates, you may find it helpful to clear the entire cache to eliminate any potential problems. You can achieve this by using <em>Purge Full Cache<\/em> button in the Cache Manager Plugin.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2020\/08\/basic-options.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"630\" height=\"141\" src=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2020\/08\/basic-options.jpg\" alt=\"Basic options - clear entire cache\" class=\"wp-image-58684\" srcset=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2020\/08\/basic-options.jpg 630w, https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2020\/08\/basic-options-300x67.jpg 300w\" sizes=\"auto, (min-width: 1360px) 876px, (min-width: 960px) calc(61.58vw + 51px), calc(100vw - 80px)\" \/><\/a><figcaption>Purge the full cache by clicking on the button<\/figcaption><\/figure><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Clearing a Single Page<\/h3>\n\n\n\n<p>If you need to diagnose a problem with a page, but do not want to purge the entire cache, you can easily purge a single page. All you have to do is either use the <em>Purge URL<\/em> feature in the Cache Manager Plugin, or prefix the URI of the page you wish to purge with <code>\/purge<\/code>, (as in the below examples).<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"643\" height=\"70\" src=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2020\/08\/clear-cache-single-page.jpg\" alt=\"Clear the cache for a single page by entering a page URL\" class=\"wp-image-58686\" srcset=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2020\/08\/clear-cache-single-page.jpg 643w, https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2020\/08\/clear-cache-single-page-300x33.jpg 300w\" sizes=\"auto, (min-width: 1360px) 876px, (min-width: 960px) calc(61.58vw + 51px), calc(100vw - 80px)\" \/><figcaption>Clear the cache for a single page by entering a page URL<\/figcaption><\/figure>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<table class=\"table table-striped\"><thead><tr><th>URL<\/th><th>Purge URL<\/th><th>What is Purged?<\/th><\/tr><\/thead><tbody><tr><td>https:\/\/example.com\/<\/td><td>https:\/\/example.com<strong>\/purge<\/strong>\/<\/td><td>Purges the homepage for example.com<\/td><\/tr><tr><td>https:\/\/example.com\/2017\/01\/cool-article<\/td><td>https:\/\/example.com<strong>\/purge<\/strong>\/2017\/01\/cool-article<\/td><td>Purges the page at <code>\/2017\/01\/cool-article<\/code><br>\u00a0<\/td><\/tr><\/tbody><\/table>\n\n\n\n<div style=\"height:33px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><a href=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2020\/08\/successful-purge-notification.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2020\/08\/successful-purge-notification.jpg\" alt=\"Example of successful purge notification\" class=\"wp-image-58689\" width=\"407\" height=\"152\" srcset=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2020\/08\/successful-purge-notification.jpg 542w, https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2020\/08\/successful-purge-notification-300x112.jpg 300w\" sizes=\"auto, (min-width: 1360px) 876px, (min-width: 960px) calc(61.58vw + 51px), calc(100vw - 80px)\" \/><\/a><figcaption>Example of successful purge notification<\/figcaption><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Troubleshooting Cache Issues<\/h2>\n\n\n\n<p>Sometimes you may find it difficult to track down caching problems \u2014 especially if you have created a complex set of rules in the Cache Manager. Below, you will find a few tips on how to glean a page\u2019s cache status by using your web browser\u2019s built-in development tools, or by using cURL.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Using Browser Development Tools<\/h3>\n\n\n\n<p>In Chrome\/Chromium, Safari, Vivaldi, or Firefox, you can open the DevTools console by pressing <code>F12<\/code>. Then, click the <em>Network<\/em> tab to view a list of all requests for the current page. If nothing displays, ensure the console shows a check in the box for <em>Disable Cache<\/em> (this refers to the browser cache, not the server-side cache) then refresh the page. Once refreshed, select the first entry in the network list (be sure to sort by \u201cCause\u201d in Firefox), which is typically the actual page request. Next, on the right-side panel under <em>Response<\/em>, a <code>X-Proxy-Cache<\/code> header will show you the cache status for this particular request. See the section below for an explanation of the various values.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"670\" height=\"291\" src=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2020\/08\/example-browser-troubleshooting-1.jpg\" alt=\"Finding the cache status\" class=\"wp-image-58691\" srcset=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2020\/08\/example-browser-troubleshooting-1.jpg 670w, https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2020\/08\/example-browser-troubleshooting-1-300x130.jpg 300w\" sizes=\"auto, (min-width: 1360px) 876px, (min-width: 960px) calc(61.58vw + 51px), calc(100vw - 80px)\" \/><figcaption>Cache status<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"699\" height=\"268\" src=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2020\/08\/example-browser-troubleshooting-2.jpg\" alt=\"Another example of checking the browser for caching status\" class=\"wp-image-58692\" srcset=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2020\/08\/example-browser-troubleshooting-2.jpg 699w, https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2020\/08\/example-browser-troubleshooting-2-300x115.jpg 300w\" sizes=\"auto, (min-width: 1360px) 876px, (min-width: 960px) calc(61.58vw + 51px), calc(100vw - 80px)\" \/><figcaption>Another example of checking the browser for caching status<\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Using cURL<\/h3>\n\n\n\n<p>If you have SSH access to your server, or a local terminal (on MacOS or Linux), you can use cURL to fetch the cache status very quickly. First, open up a terminal window or SSH session, then run the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>user@server ~ $ curl -A Mozilla -is https:\/\/example.com\/ | \nhead -15<\/code><\/pre>\n\n\n\n<p>Be sure to substitute the URL in the above example with the one you would like to test. This should provide a list of the response headers, including the <code>X-Proxy-Cache<\/code> header.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Using ngxutil<\/h3>\n\n\n\n<p><strong>(VPS\/Dedicated only)<\/strong><br>A tool that we developed in-house for use with the WordPress Optimized Stack, ngxutil performs many useful tasks. For this discussion, we will focus on its <code>--info<\/code> functionality. This function makes a request to the provided URL, then shows the current state of the cache on disk, checks whether the page was served from cache, and provides general troubleshooting tips in case you run into problems or receive errors.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@vpsdedi ~]# ngxutil --info https:\/\/example.com\/<\/pre>\n\n\n\n<pre>GET https:\/\/example.com\/ Elapsed: 0.157s --- 200 OK \nCache status: MISS * NOT IN CACHE --- * \nContent compressed\/encoding via gzip * \nVary on Accept-Encoding enabled * \nClient cache-control headers present: Cache-Control: private, must-revalidate --- * \nOne or more cookies are being set by the server TIP: \nCookies will prevent the page from being cached, unless\ncache_honor_cookies is set to false in the ngxconf config\nfor this domain (default: true). \n\nIf session management is necessary, offloading these requests\nto an AJAX endpoint via client-side Javascript will provide \nthe best performance. laravel_session = 'xxxyyyzzz' XSRF-TOKEN =\n'xxxyyyzzz' ---<\/pre>\n\n\n\n<p>This method requires root SSH access and only applies to VPS and Dedicated customers running the WordPress Optimized Stack. Please refer to our article on <a href=\"https:\/\/www.inmotionhosting.com\/support\/server\/ssh\/how-to-login-ssh\/\">connecting via ssh<\/a> for instructions on getting connected.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Cache Statuses<\/h3>\n\n\n\n<p>Below, you will find a table describing all possible values for the <code>X-Proxy-Cache<\/code> header. Use it along with the above techniques for checking cache status for your web pages.<\/p>\n\n\n\n<table class=\"table table-striped\"><thead><tr><th>Status<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>-<\/code> (Empty or no header)<\/td><td>No caching configured for this URI, or the page was requested via a method other than <code>GET<\/code>, <code>HEAD<\/code>, or <code>OPTIONS<\/code>. This means that <code>POST<\/code> requests will always bypass the cache<\/td><\/tr><tr><td><code>HIT<\/code><\/td><td>NGINX found a matching page in the cache and returned it to the visitor. The returned page has not yet expired.<\/td><\/tr><tr><td><code>MISS<\/code><\/td><td>No matching fresh page was found in the cache. NGINX made a request to the origin (Apache, PHP-FPM), then cached the resulting page for subsequent requests.<\/td><\/tr><tr><td><code>EXPIRED<\/code><\/td><td>NGINX tried to retrieve an updated page from the origin (Apache, PHP-FPM), but encountered an error, so instead, it served an expired page from the cache.<\/td><\/tr><tr><td><code>UPDATING<\/code><\/td><td>NGINX is currently waiting for a response from Apache to update the cache (from a previous request). In the meantime, NGINX served the visitor the existing (expired) page from the cache. This behavior can be controlled via the <code>cache_lock_enable<\/code> option (enabled by default; this option is not available via the Cache Manager Plugin interface, as it should remain enabled in most cases).<\/td><\/tr><tr><td><code>BYPASS<\/code><\/td><td>This page was passed directly to\/from Apache without caching due to matching a pattern in the <em>Bypass URLs<\/em> list. Other options, such as <em>Bypass Cookies<\/em>, also influence whether or not the request bypassed the cache.<\/td><\/tr><tr><td><code>STATIC\/TYPE<\/code><\/td><td>This asset was served directly by NGINX due to matching the file extension of the request URL with a predefined list in the server template. This is enabled or disabled via the <em>Accelerate Static Content<\/em> option. A URL can forcibly bypass this by being added to the <em>Force Passthru<\/em> list.<\/td><\/tr><tr><td><code>STATIC\/PATH<\/code><\/td><td>This asset was served directly by NGINX due to matching a path in the <em>Static Content Paths<\/em> list.<\/td><\/tr><\/tbody><\/table>\n\n\n\n<p>NGINX and the various cache options provided by the WordPress Optimized Stack make for powerful tools you can use to tune your website for optimal performance. With this guide, you should be able to start making changes to help optimize your website for the best performance!<\/p>\n\n\n\n<p>Learn more from our <a href=\"https:\/\/www.inmotionhosting.com\/support\/product-guides\/wordpress-hosting\/\">WordPress Hosting Product Guide<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p><!-- Cache Management with NGINX --> <!-- introduction --> <\/p>\n<p>In this article, we will explore the various NGINX cache configuration options, and tips on tweaking your site to get the best performance out of the WordPress Optimized Stack. This guide covers all of the most common parameters you can tune via the Cache Manager Plugin. <\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4288,56],"tags":[],"class_list":["post-4307","post","type-post","status-publish","format-standard","hentry","category-website","category-wordpress"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>NGINX Cache Management<\/title>\n<meta name=\"description\" content=\"Learn about NGINX Cache Management. This article explores the various NGINX cache configuration options and tips on tweaking your site to improve performance through the cache.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.inmotionhosting.com\/support\/website\/nginx-cache-management\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"NGINX Cache Management\" \/>\n<meta property=\"og:description\" content=\"Learn about NGINX Cache Management. This article explores the various NGINX cache configuration options and tips on tweaking your site to improve performance through the cache.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.inmotionhosting.com\/support\/website\/nginx-cache-management\/\" \/>\n<meta property=\"og:site_name\" content=\"InMotion Hosting Support Center\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/inmotionhosting\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-01-25T01:37:27+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-05-10T16:12:34+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2020\/08\/nginx-cache-time-1.jpg\" \/>\n<meta name=\"author\" content=\"InMotion Hosting Contributor\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/InMotionHosting\" \/>\n<meta name=\"twitter:site\" content=\"@InMotionHosting\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"InMotion Hosting Contributor\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/nginx-cache-management\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/nginx-cache-management\/\"},\"author\":{\"name\":\"InMotion Hosting Contributor\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/8d626175dd3b70ee90a172bdb09a460b\"},\"headline\":\"NGINX Cache Management\",\"datePublished\":\"2018-01-25T01:37:27+00:00\",\"dateModified\":\"2024-05-10T16:12:34+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/nginx-cache-management\/\"},\"wordCount\":2007,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/nginx-cache-management\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2020\/08\/nginx-cache-time-1.jpg\",\"articleSection\":[\"Website\",\"WordPress Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/website\/nginx-cache-management\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/nginx-cache-management\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/website\/nginx-cache-management\/\",\"name\":\"NGINX Cache Management\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/nginx-cache-management\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/nginx-cache-management\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2020\/08\/nginx-cache-time-1.jpg\",\"datePublished\":\"2018-01-25T01:37:27+00:00\",\"dateModified\":\"2024-05-10T16:12:34+00:00\",\"description\":\"Learn about NGINX Cache Management. This article explores the various NGINX cache configuration options and tips on tweaking your site to improve performance through the cache.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/nginx-cache-management\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/website\/nginx-cache-management\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/nginx-cache-management\/#primaryimage\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2020\/08\/nginx-cache-time-1.jpg\",\"contentUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2020\/08\/nginx-cache-time-1.jpg\",\"width\":423,\"height\":94},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/nginx-cache-management\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.inmotionhosting.com\/support\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"NGINX Cache Management\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"name\":\"InMotion Hosting Support Center\",\"description\":\"Web Hosting Support &amp; Tutorials\",\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\",\"name\":\"InMotion Hosting\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"contentUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"width\":696,\"height\":696,\"caption\":\"InMotion Hosting\"},\"image\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/inmotionhosting\/\",\"https:\/\/x.com\/InMotionHosting\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/8d626175dd3b70ee90a172bdb09a460b\",\"name\":\"InMotion Hosting Contributor\",\"description\":\"InMotion Hosting contributors are highly knowledgeable individuals who create relevant content on new trends and troubleshooting techniques to help you achieve your online goals!\",\"sameAs\":[\"https:\/\/www.linkedin.com\/company\/inmotion-hosting\/\",\"https:\/\/x.com\/https:\/\/twitter.com\/InMotionHosting\"],\"url\":\"https:\/\/www.inmotionhosting.com\/support\/author\/arn\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"NGINX Cache Management","description":"Learn about NGINX Cache Management. This article explores the various NGINX cache configuration options and tips on tweaking your site to improve performance through the cache.","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:\/\/www.inmotionhosting.com\/support\/website\/nginx-cache-management\/","og_locale":"en_US","og_type":"article","og_title":"NGINX Cache Management","og_description":"Learn about NGINX Cache Management. This article explores the various NGINX cache configuration options and tips on tweaking your site to improve performance through the cache.","og_url":"https:\/\/www.inmotionhosting.com\/support\/website\/nginx-cache-management\/","og_site_name":"InMotion Hosting Support Center","article_publisher":"https:\/\/www.facebook.com\/inmotionhosting\/","article_published_time":"2018-01-25T01:37:27+00:00","article_modified_time":"2024-05-10T16:12:34+00:00","og_image":[{"url":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2020\/08\/nginx-cache-time-1.jpg","type":"","width":"","height":""}],"author":"InMotion Hosting Contributor","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/InMotionHosting","twitter_site":"@InMotionHosting","twitter_misc":{"Written by":"InMotion Hosting Contributor","Est. reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.inmotionhosting.com\/support\/website\/nginx-cache-management\/#article","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/website\/nginx-cache-management\/"},"author":{"name":"InMotion Hosting Contributor","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/8d626175dd3b70ee90a172bdb09a460b"},"headline":"NGINX Cache Management","datePublished":"2018-01-25T01:37:27+00:00","dateModified":"2024-05-10T16:12:34+00:00","mainEntityOfPage":{"@id":"https:\/\/www.inmotionhosting.com\/support\/website\/nginx-cache-management\/"},"wordCount":2007,"commentCount":0,"publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"image":{"@id":"https:\/\/www.inmotionhosting.com\/support\/website\/nginx-cache-management\/#primaryimage"},"thumbnailUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2020\/08\/nginx-cache-time-1.jpg","articleSection":["Website","WordPress Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.inmotionhosting.com\/support\/website\/nginx-cache-management\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.inmotionhosting.com\/support\/website\/nginx-cache-management\/","url":"https:\/\/www.inmotionhosting.com\/support\/website\/nginx-cache-management\/","name":"NGINX Cache Management","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.inmotionhosting.com\/support\/website\/nginx-cache-management\/#primaryimage"},"image":{"@id":"https:\/\/www.inmotionhosting.com\/support\/website\/nginx-cache-management\/#primaryimage"},"thumbnailUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2020\/08\/nginx-cache-time-1.jpg","datePublished":"2018-01-25T01:37:27+00:00","dateModified":"2024-05-10T16:12:34+00:00","description":"Learn about NGINX Cache Management. This article explores the various NGINX cache configuration options and tips on tweaking your site to improve performance through the cache.","breadcrumb":{"@id":"https:\/\/www.inmotionhosting.com\/support\/website\/nginx-cache-management\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.inmotionhosting.com\/support\/website\/nginx-cache-management\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.inmotionhosting.com\/support\/website\/nginx-cache-management\/#primaryimage","url":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2020\/08\/nginx-cache-time-1.jpg","contentUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2020\/08\/nginx-cache-time-1.jpg","width":423,"height":94},{"@type":"BreadcrumbList","@id":"https:\/\/www.inmotionhosting.com\/support\/website\/nginx-cache-management\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.inmotionhosting.com\/support\/"},{"@type":"ListItem","position":2,"name":"NGINX Cache Management"}]},{"@type":"WebSite","@id":"https:\/\/www.inmotionhosting.com\/support\/#website","url":"https:\/\/www.inmotionhosting.com\/support\/","name":"InMotion Hosting Support Center","description":"Web Hosting Support &amp; Tutorials","publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.inmotionhosting.com\/support\/#organization","name":"InMotion Hosting","url":"https:\/\/www.inmotionhosting.com\/support\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/","url":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","contentUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","width":696,"height":696,"caption":"InMotion Hosting"},"image":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/inmotionhosting\/","https:\/\/x.com\/InMotionHosting"]},{"@type":"Person","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/8d626175dd3b70ee90a172bdb09a460b","name":"InMotion Hosting Contributor","description":"InMotion Hosting contributors are highly knowledgeable individuals who create relevant content on new trends and troubleshooting techniques to help you achieve your online goals!","sameAs":["https:\/\/www.linkedin.com\/company\/inmotion-hosting\/","https:\/\/x.com\/https:\/\/twitter.com\/InMotionHosting"],"url":"https:\/\/www.inmotionhosting.com\/support\/author\/arn\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"primary_category":{"id":4288,"name":"Website","slug":"website","link":"https:\/\/www.inmotionhosting.com\/support\/website\/"},"_links":{"self":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/4307","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/comments?post=4307"}],"version-history":[{"count":30,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/4307\/revisions"}],"predecessor-version":[{"id":83783,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/4307\/revisions\/83783"}],"wp:attachment":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/media?parent=4307"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/categories?post=4307"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/tags?post=4307"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}