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:
- Go to Service Plans.
- 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.
- Go to the “Web Server” tab.
- In the “nginx settings” section, select the “Enable nginx caching” checkbox.
- (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.
- 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.
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.
[webserver] ; 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