How to optimise FastCGI for Wordpress?

Hello,

Honestly, I have no idea about all this, so I was talking to ChatGPT and he pointed me to some steps to optimize fastcgi for my wordpress websites…

The result, horrible hahaha

Well, this is what I’m doing, maybe someone can help me to optimize and fix the error.

Not if it’s helpful but it’s a 2vcpu 8GB ram VPS with HestiaCp+Nginx+Redis+Fastcgi+PHP.FPM

What I am doing is modifying the config file of:

nano /home/Clemenza/conf/web/test2.gathijos.es/nginx.fastcgi_cache.conf

The content was this:

fastcgi_cache test2.gathijos.es;
 fastcgi_cache_valid 200 30d;
 fastcgi_cache_valid 301 302 10m;
 fastcgi_cache_valid 404 10m;
 fastcgi_cache_bypass $no_cache;
 fastcgi_no_no_cache $no_cache;
 set $no_cache 0;

ChatgGPT has asked me to delete it and put this one:

nginx
fastcgi_cache_path /var/cache/nginx/test2.gathijos.es levels=1:2 keys_zone=test2_gathijos_cache:100m inactive=60m max_size=1g;

map request_methodpurge_method {
 default 0;
 PURGE 1;
}

set no_cache 0;

No cache if user is logged in or there are specific cookies
if (http_cookie ~* "comment_author|wordpress_[a-z0-9]+|wp-postpass|wordpress_logged_in") {
 set no_cache 1;

fastcgi_cache_bypassno_cache;
fastcgi_no_cache no_cache;

fastcgi_cache test2_gathijos_cache;
fastcgi_cache_valid 200 301 302 60m;
fastcgi_cache_valid 404 10m;
fastcgi_cache_use_stale error timeout updating http_500 http_503;
add_header X-FastCGI-Cacheupstream_cache_cache_status;

And then save and run the following:

sudo nginx -t && sudo systemctl reload nginx

But when I do it, I get this error:

nginx: [emerg] unknown directive “nginx” in /home/Clemenza/conf/web/test2.gathijos.es/nginx.fastcgi_cache.conf:3
nginx: configuration file /etc/nginx/nginx.conf test failed

So I don’t know what’s going on and ChatGPT either, because it’s asking me to delete this and change that, but the problem doesn’t get fixed.

Can anyone help me with this?

Do I need to edit any other file, apart from this one, to optimize fastcgi’s performance properly?

My intention is to optimize fastcgi as much as possible for my wordpress and also to make the TTFB as good as possible.