Symptoms
-
In Plesk under Home > Domains > Apache & Nginx Settings the setting Cache timeout has been set to a higher value than 10 minutes.
Note: The option Enable nginx caching has to be enabled to be able to view this set.
-
During testing with a command such as
curl -I http://example.com/
the following can be observed:Request 1 at 09:06:03 GMT: Cache hit
# curl -I http://example.com/
HTTP/1.1 200 OK
Server: nginx
Date: Tue, 26 Jun 2018 09:06:03 GMT
…
X-Cache-Status: HIT
…Request 2 at 09:25:01 GMT: Cache miss
# curl -I http://example.com/
HTTP/1.1 200 OK
Server: nginx
Date: Tue, 26 Jun 2018 09:25:01 GMT
…
X-Cache-Status: MISS
…The X-Cache-Status does not hold its value for as long as it was set.
Cause
A bug in Plesk with id #PPPM-8888 which is planned to be fixed in future updates.
Resolution
Note: Nginx caching is mostly used for short caching periods with mostly under 10 minutes of the cache files lasting.
It is possible to change the inactive timeout of the cache files to a higher value.
In the example below, the inactive timeout will be changed to 5 hours:
-
Connect to the server via SSH
-
Create the directories
# mkdir -p /usr/local/psa/admin/conf/templates/custom/domain/service/
-
Copy the default template over
# cp /usr/local/psa/admin/conf/templates/default/domain/service/nginxCachePath.php /usr/local/psa/admin/conf/templates/custom/domain/service/nginxCachePath.php
-
Add the directive inactive=5h to set the timeout to five hours by executing the following:
# sed -i.backup “/proxySettings[‘nginxCacheSize’]/s/$/ . ‘ inactive=5h’/” /usr/local/psa/admin/conf/templates/custom/domain/service/nginxCachePath.php
Note: The layout may vary depending on the Plesk version. The inactive=5h responsible for the time the files should be stored in the cache. For more information regarding the possible values check the Nginx documentation here.
-
Reconfigure all domains to apply the changes in configuration template
# plesk repair web -domains-only
Warning: The solution might cause downtime to the websevices and therefore should only be run during maintance window.