Enabling nginx caching

Enabling nginx caching allows the nginx proxy server to cache certain website dynamic content. The cached data is stored for a short time (usually no more than several seconds). This can help speed up the website load time and reduce server load.

Enabling nginx caching is recommended only for websites with a specific profile (for example, popular blogs or news websites):

  • High traffic.
  • The content is updated every few seconds.

Enabling nginx caching can be useless or even harmful for websites with the following profile:

  • Moderate or low traffic.
  • The content is updated less often than every few seconds.
  • Personalized content is used (for example, the visitor’s geographical location or the contents of their shopping cart).

You can enable nginx caching for individual domains or hosting plans.

To enable nginx caching for a hosting plan:

  1. Go to Service Plans.
  2. On the “Hosting Plans” tab, either click Add a Plan to create a new plan or click the name of an existing plan to edit it.
  3. Go to the “Web Server” tab.
  4. In the “nginx settings” section, select the “Enable nginx caching” checkbox.
  5. (Optional) You can customize nginx caching settings. If you are not familiar with nginx caching, we recommend that you keep the default settings. Misconfiguring these settings can hinder the website and server performance.
  6. Click OK (or Update & Sync if editing an existing plan).

Now, every time you create a new subscription based on this hosting plan, nginx caching will be automatically enabled on that subscription’s domains and subdomains. Existing subscriptions based on this hosting plan will not be affected.

To learn how to enable nginx caching for a domain, click here.

Customizing the default nginx caching settings

You can set the default values for a number of nginx caching settings (for example, cache size, cache timeout, and so on) by editing the panel.ini file. The customized values will be applied to newly created hosting plans, domains, and subdomains, and will not affect those that already exist.

See below for the list of nginx caching settings that you can customize via the panel.ini file.

; path where to store cache
nginxCacheDir = /var/cache/nginx
; default values
nginxCacheEnabled = off
nginxCacheSize = 62914560
nginxCacheTimeout = 5
nginxCacheKey = $scheme$request_method$host$request_uri
nginxCacheCookies = ""
nginxCacheBypassLocations = ""
nginxCacheBypassHeaderNocache = on
nginxCacheBypassHeaderAuth = on
nginxCacheBypassGetNocache = on
nginxCacheUseStale5xx = on
nginxCacheUseStale4xx = off
nginxCacheUseStaleUpdating = on
; maximum values
nginxCacheSizeMax = 1099511627776
nginxCacheTimeoutMax = 3153600000