• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • We are looking for U.S.-based freelancer or agency working with SEO or WordPress for a quick 30-min interviews to gather feedback on XOVI, a successful German SEO tool we’re looking to launch in the U.S.
    If you qualify and participate, you’ll receive a $30 Amazon gift card as a thank-you. Please apply here. Thanks for helping shape a better SEO product for agencies!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

Question Nginx FastCGI microcaching

Émerson Felinto

Regular Pleskian
Enable Nginx FastCGI microcaching

I really need to enable this feature for my clients. I tried to do it manually but nothing I did worked out, I also do not know how to tell if microcaching is actually active on my site.
There are already questions in the forum related to this, but nobody gave a solution that works to activate microcaching in Plesk, someone who has already managed to install and configure has some solution?
 
Interesting question. Here is an attempt to provide support - no guarantee on this, though. I did not test it and have not done it before.

You need to put these commands before and into the "server" brackets of /etc/nginx/plesk.conf.d/server.conf like this:
Code:
proxy_cache_path /tmp/cache keys_zone=cache:10m levels=1:2 inactive=600s max_size=100m;
server {
   proxy_cache cache;
   proxy_cache_valid 200 1s;
   # ...
}
and restart Nginx aftwards. (Example taken from Nginx documentation).

However, the /etc/nginx/plesk.conf.d/server.conf is auto-generated by Plesk. It is probably necessary to create a user template for this file to have these global changes applied to Nginx. The default configuration template for this should be /usr/local/psa/admin/conf/templates/default/nginx.php. The default should NOT be modified. Instead, copy the default to /usr/local/psa/admin/conf/templates/custom/ (the "custom" directory needs to be created for that if it does not yet exist) and edit the custom version of nginx.php there. Now after your custom nginx.php including the special microcaching directives exists, run
# /usr/local/psa/admin/sbin/httpdmng --reconfigure-all
to have Plesk rebuild all configuration files. (I am not aware that it is possible to limit the rebuild process to only the Nginx global files.)
 
I did everything as described, but it just is not working. Is there any way to know Microcaching Nginx is active? I put it to the server to report in the HTTP headers, but it just does not seem to work:

-rw-r--r-- 1 root root 1952 Oct 18 02:08 /usr/local/psa/admin/conf/templates/custom/nginx.php

<?php echo AUTOGENERATED_CONFIGS; ?>

<?php /** @var Template_VariableAccessor $VAR */ ?>
<?php /** @var Template_Variable_IpAddress $ipAddress */ ?>

include "<?php echo $VAR->server->nginx->httpConfDir ?>/plesk.conf.d/ip_default/*.conf";

<?php echo $VAR->includeTemplate('server/nginxVhosts.php', array(
'ssl' => false,
'frontendPort' => $VAR->server->nginx->httpPort,
'backendPort' => $VAR->server->webserver->httpPort,
)) ?>

<?php echo $VAR->includeTemplate('server/nginxVhosts.php', array(
'ssl' => true,
'frontendPort' => $VAR->server->nginx->httpsPort,
'backendPort' => $VAR->server->webserver->httpsPort,
)) ?>

<?php /* Next block used for watchdog */ ?>
<?php if (!$VAR->server->ipAddresses->hasIpV4Address): ?>
server {
listen 127.0.0.1 default_server;
return 200;
}
server {
fastcgi_ignore_headers Cache-Control Expires;
fastcgi_cache_path /tmp/cache levels=1:2 keys_zone=thelastcicada:900m inactive=10m max_size=100m;
fastcgi_cache_key "$scheme://$host$request_method$request_uri";

#Cache everything by default
set $no_cache 0;

#Don't cache logged in users or commenters
if ( $http_cookie ~* "comment_author_|wordpress_(?!test_cookie)|wp-postpass_" ) {
set $no_cache 1;
}

#Don't cache the following URLs
if ($request_uri ~* "/(wp-admin/|wp-login.php)")
{
set $no_cache 1;
}

#matches keys_zone in fastcgi_cache_path
fastcgi_cache thelastcicada;

#don't serve pages defined earlier
fastcgi_cache_bypass $no_cache;

#don't cache pages defined earlier
fastcgi_no_cache $no_cache;

#defines the default cache time
fastcgi_cache_valid any 10s;

#unsure what the impacts of this variable is
fastcgi_max_temp_file_size 2M;

#Use stale cache items while updating in the background
fastcgi_cache_use_stale updating error timeout invalid_header http_500;
fastcgi_cache_lock on;
fastcgi_cache_lock_timeout 10s;

fastcgi_cache_key “$scheme://$host$request_method$request_uri”;
}
<?php endif ?>
 
Back
Top