Blog

Provide customers with quality service is always our mission, customer recognition is always our pursuit!

How to enable fastcgi_cache caching for Pagoda Panel Nginx? WordPress Speed Up

In this article, we will explain how to enable fastcgi_cache caching in Nginx via Pagoda Panel to improve the access speed of your WordPress website and reduce the burden on the server. First, we will briefly introduce the concept and role of fastcgi_cache cache. Then, we will give a detailed guide on how to configure Nginx to enable fastcgi_cache cache in Pagoda panel to set up the plugin.

 

 

What is fastcgi_cache cache?

fastcgi_cache is a caching mechanism provided by Nginx to improve the performance of dynamic content. It is particularly suited to applications that deal with the FastCGI protocol, such as PHP (Wordpress). fastcgi_cache enables static web pages at the system level, greatly reducing server load, concurrency, and providing increased site loading speed.

 

 

What are the advantages of fastcgi_cache caching?

Many people will be curious, for Wordpress, fastcgi_cache cache and regular through Wp Rocket and other plug-ins to achieve the cache what is the difference? fastcgi_cache cache is thesystem levelCaching, handled only by Nginx (PHP is not involved), so it's fast and can take a lot of concurrency. The downside is that it's not as flexible, has fewer features, and is a bit of a barrier to use, so white people rarely hear about this cache.

pass (a bill or inspection etc)Wp RocketThe caching implemented by plugins such assoftware levelThe cache is handled by PHP (Nginx is not involved), so it is slower and takes up more server resources. Advantages are controlled by plug-ins, easy to use and understand, very flexible, feature-rich, the public's favorite.

We deal with servers all the time, dealing with high concurrency and lagging issues. Most of the time, memory is exhausted or CPU is overloaded because PHP is running a huge task. fastcgi_cache cache does not need to run PHP, so it takes up much less resources, greatly reducing the burden on the server.

At the same time fastcgi_cache cache is handled by Nginx, so the computation link is much shorter than the cache implemented by plugins such as Wp Rocket, and therefore faster. fastcgi_cache cache is even faster than Litespeed cache cache in some environments!

Comparison of average response times for various caches↓ (shorter is better).

Pasted 108

 

Attention:FastCGI_Cache on the server performance requirements, if it is 1H1G and other low configuration, and then how to optimize the effect is not obvious.

Now most people use Pagoda Panel to build websites, which is convenient and time-saving. Below is the method to open FastCGI_Cache cache in Pagoda Panel.

Note: Since FastCGI_Cache caches PHP requests, it may cause site exceptions. For example, read count invalidation, caching of commenter information, caching of login screen, etc. Additional code needs to be added to exclude this. Therefore, it is not recommended for newbies to use FastCGI_Cache caching.FastCGI_Cache caching requires the use of a specialized caching plugin.

 

 

How Nginx enables fastcgi_cache caching

The Pagoda panel compiles the Nginx ngx_cache_purge module by default, so you don't need to install it additionally, just follow the tutorial below.

 

 

global setting

1 Log in to Pagoda background, find Nginx in the software store, click the Settings button, and add the following contents in the "Configuration Modification":

fastcgi_cache_path /tmp/wpcache levels=1:2 keys_zone=WORDPRESS:250m inactive=1d max_size=1G;fastcgi_temp_path /tmp/wpcache/temp;fastcgi_ cache_key "$scheme$request_method$host$request_uri";fastcgi_cache_use_stale error timeout invalid_header http_500;# Ignore all nocache declarations to avoid not caching pseudo-static etc fastcgi_ignore_headers Cache-Control Expires Set-Cookies;

Screenshot below after adding it:

Pasted 104

 

 

Website Setup

Find the corresponding website in the list of websites in Pagoda background, click the "Settings" button, add the following code to the configuration file, and enter the IP (extranet) address of the web server in line 43.The code has to be adjusted as needed! It varies from site to site! Once again, I'm discouragedyoung whiteThe

set $skip_cache 0;#post access is not cached if ($request_method = POST) {set $skip_cache 1;} # dynamic queries are not cached if ($query_string ! = "") {set $skip_cache 1;} # Backend and other specific pages are not cached (just add your own for other requirements) if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-. *.php|/feed/|index.php|sitemap(_index)? .xml") {set $skip_cache 1;} #Display no cache for logged in users, commented users if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_ no_cache|wordpress_logged_in") {set $skip_cache 1;}# Here please refer to the previous configuration of your site, especially the path of the sock, get it wrong will show 502! .php(/|$){ try_files $uri =404; fastcgi_pass unix:/tmp/php-cgi-74.sock; fastcgi_index index.php; include fastcgi.conf; add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload"; # new cache rules fastcgi_cache_bypass $skip_cache; fastcgi_no_ cache $skip_cache; add_header X-Cache "$upstream_cache_status From $host"; fastcgi_cache WORDPRESS; add_header Cache-Control max- age=0; add_header Nginx-Cache "$upstream_cache_status"; add_header Last-Modified $date_gmt; add_header X-Frame-Options SAMEORIGIN; # Only allow this site to nest with frames add_header X-Content-Type-Options nosniff; # Disable sniffing of file types add_header X-XSS-Protection "1; mode=block"; # XSS Protection etag on; fastcgi_cache_valid 200 301 302 1d;}# Cache cleanup configuration location ~ /purge(/. *) {allow 127.0.0.1;allow "server extranet IP"; # quotes to be kept deny all;fastcgi_cache_purge WORDPRESS "$scheme$request_method$host$1";}

Screenshot below after adding it:

Pasted 105

After adding and saving, restart Nginx on it. The next step is to install the Setup Cache plugin ↓.

 

 

Installing the WordPress Clean Cache plugin

FastCGI_Cache is unable to automatically and accurately clean the site cache in a timely manner, so you will need to install the companion caching plugin to automatically control refreshing the cache. Background search, installationNginx Helperplugin, this plugin is built specifically for fastcgi_cache caching.

The plugin settings are referenced in the image below (image source. Zhang Ge Blog).

fastcache

Cleanup mode selects Delete local server cache files to delete cache files directly from the server and then regenerate them.

My friend Milkman's website test found that Nginx fastcgi_cache cache (404ms) is a little faster than WP Super Cache + Memcached Object Cache cache (455ms).

 

 

Determining Cache Status

Open the frontend of the website in incognito mode of your browser (not logged in), press F12 to go to Developer Tools > Network > Tap on the URL > Tap on the "Header" to view the details.

Pasted 106

Pasted 107

HIT: Cache Success
MISS: Cache failure, suggest refreshing the page 2 times to see if it has become HIT.
BYPASS: Skip Cache
EXPIRED: Cache expired

 

 

Advanced Tutorials

indeedThe fastcgi_cache cache can also be used with the Wp Rocket cache plugin. Using it together is more effective than using theWp Rocket is about 27% higher than the standaloneThe fastcgi_cache cache is not much different. Just install therocket-nginx, just configure it appropriately.This method has a high threshold for use, so don't use it if you don't know how.

Scroll to Top