Nginx cache configuration

Activating Proxy Template “wordpress.tpl” I found two issues, google does not helps.

sudo /usr/local/hestia/bin/v-add-fastcgi-cache admin domain.com 30m yes yes
Error: nginx is in proxy mode
Why? nginx is in php-fpm mode via socket for this domain

instruction
include /home/admin/conf/web/domain.com/nginx.fastcgi_cache.conf*;
has no file to include

Are there some template/ example of this nginx.fastcgi_cache.conf ?

The code checks if Nginx+PHP-FPM is active for the whole server or not.

If so the option is available for rebuild, restore and edit web. If not the software doesn’t under stand it yet. Changing this behaviour would requiring a complete rewrite of Hestia and it yet not in the planning.

If you check the code for v-add-fastcgi-cache you are able to see the template used.

Thanks for the explanation.

The code checks if Nginx+PHP-FPM is active for the whole server or not.
Ok, so I just made changes for every website on this machine like that
Screenshot by Lightshot
Or I should activate it somewhere else?

But just wonder if there is a way to make it globally or not?

BTW I already check the file you point me to. The line

if [ “$WEB_SYSTEM” != ‘nginx’ ]; then
contents variable $WEB_SYSTEM, but echo $WEB_SYSTEM shows empty. A bit strange…

Loads the variable as in /usr/local/hestiacp/conf/hestia.conf

Incase of Apache2 + Nginx

WEB_BACKEND='php-fpm'
WEB_PORT='8080'
WEB_RGROUPS='www-data'
WEB_SSL='mod_ssl'
WEB_SSL_PORT='8443'
WEB_SYSTEM='apache2'

Incase of Nginx + FPM

WEB_PORT='80'
WEB_SSL='openssl'
WEB_SSL_PORT='443'
WEB_SYSTEM='nginx'

If the are not present you should be able to add them safely.

If you want to move from Nginx + Apache2 to Nginx + PHP-FPM
Run this script and it will update all settings as it should be…

Thank you, it helps a lot.
However as I see there is some incompatibility with wp-super-cache plugin, could be it brakes some headers of nginx.

Can you please suggest a way to separate a cache for mobile devices?

Yes. I think that eris had a wp plugin for that?

Not sure.
The only plugin I found is Hestia Nginx Cache By Jakob Bouchard - cache flusher.

BTW I suggest to add this block to nginx templates

        #Don't cache POST requests
        if ($request_method = POST) {
            set $no_cache 1;
        }

Currently working on:

But it works with the fact the that a few custom modules are loaded an configured in a special way.

Thanks, but the question was NOT about purging

Can you please suggest a way to separate a cache for mobile devices?

I meant to keep two versions of the cache, one for mobile, one for desktop

In the file /etc/nginx/conf.d/fastcgi_cache_pool.conf we see inactive=10m; parameter for every domain.
Is there a way to change this globally for all the old and new domains via panel or via some config file?
Or even delete “inactive=10m” at all.

It is supposed to be 30m

But it does delete inactive files if they haven’t been accessed for over 30 min or longer

Thank you eris.

Exactly. So for low traffic webs its important to keep a cached version, so I always re-generate cache every 6 h using “heating” script, so I set inactive=400m

Please note the script get overwritten each update + config get almost each update…

Thank for this notice.
I will turn off updates in this case.

I made a change in one of proxy templates
/usr/local/hestia/data/templates/web/nginx/php-fpm/wordpress.stpl

Now the question is how to re-save all the sites conf’s (~10)+ which are using this template to update it?
Is there some bash script exists?

BTW I add a solution is to serve webp via nginx;

I add this code to the template

        location ~* ^.+\.(png|jpg)$ {
            add_header Vary Accept;
            try_files $uri$webp_suffix $uri =404;
            expires 90d;
            fastcgi_hide_header "Set-Cookie";
		}

and the code below save to /etc/nginx/conf.d/webp_extention.conf

map $http_accept $webp_suffix {
    default   "";
    "~*webp"  ".webp";
  }

Now by the next two lines I can generate webp for ALL the png/jpg on all the webs

find /home/ -type f -name '*.jpg' -print0 | xargs -0n1 -P$(nproc) -i cwebp -m 6 -q 24 -af '{}' -o '{}'.webp

find /home. -type f -name '*.png' -print0 | xargs -0n1 -P$(nproc) -i cwebp -m 6 -q 70 -af '{}' -o '{}'.webp

v-rebuild-web-domain user domain or via the UI

But you should never update an “hestia” supplied template as they will get overwritten after next update

See the Headers

#=========================================================================#
# Default Web Domain Template                                             #
# DO NOT MODIFY THIS FILE! CHANGES WILL BE LOST WHEN REBUILDING DOMAINS   #
# https://docs.hestiacp.com/admin_docs/web.html#how-do-web-templates-work #
#=========================================================================#

Thanks.
I turned off auto updates.

Renaming templates will also work…

Updates can contain bug fixes but also security patches

1 Like

Sure.
But I never use autoupdate: better to wait for a stable release than get server fault in case of some bug in production :wink: