If you are running a WordPress website, using FastCGI caching to improve performance should be considered. When you combine Nginx and FastCGI modules, you will greatly improve your PHP-based applications. FastCGI module caches dynamic PHP content that is served through the Nginx backend. When dynamic PHP content is cached, repeated requests for the same content are quickly returned from the cache store, instead of compiling all the dynamic data that make up the page each time a request is made.
How to enable FastCGI caching with Nginx on Ubuntu Linux
As described above, when you combine Nginx and FastCGI modules, you will greatly improve your PHP-based applications. FastCGI module caches dynamic PHP content that is served through the Nginx backend. Below is how to enable FastCGI caching with Nginx on Ubuntu Linux. First, install the PHP FastCGI module. You can do that by running the commands below. This article assumes that you have Nginx installed and it’s functioning. If you haven’t installed Nginx, read the post below to do so. How to install Nginx on Ubuntu Linux
Set up FastCGI Nginx directive
On Ubuntu Linux, Nginx configuration files are stored in the /etc/nginx directory. Open Nginx main configuration file (nginx.conf). Run the commands below to open the Nginx configuration file. Once the file is opened, copy and content below and paste it at the end of the file, then save.
Configure website server block
After updating Nginx main config file with the lines above, open your website server block. On Ubuntu Linux, website server blocks are typically stored in /etc/nginx/sites-available/ Run the commands below to open the default server block file. Then copy and paste the content below into the file. Usually under the PHP section of the file, then save. If everything is set up correctly, PHP should be going through the FastCGI module and caching enabled. If you are running a WordPress website, you may also include the code below in the website server block file. This will help you skip caching of the backend portal, sitemap, and other files you don’t want to cache. Save your settings and you are done. Conclusion: This post showed you how to run the Nginx HTTP server with FastCGI caching module. If you find any error above or have something to add, please use the comment form below.