Earlier we used to cache our wordpress sites using PHP-FPM technology. We have a tutorial for this: FastCGI Caching with Nginx on VPS for WordPress
Now, we cache our sites in a simpler and better method. We use a wordpress plugin named Simple Cache. And we shall order Nginx server to serve the cached content bypassing the database query and PHP. Here are the steps:
Step 1. Install and Activate the plugin Simple Cache.
Step 2: Add the following into wp-config.php if the plugin can’t do it for you.
define('WP_CACHE', TRUE);
Step 3: Edit virtual host file. e.g.
sudo nano /etc/nginx/sites-available/wbxpress.conf
Replace the following line inside location / block:
try_files $uri $uri/ /index.php?$args;
By
try_files "wp-content/cache/simple-cache/${http_host}${request_uri}index.html" $uri $uri/ /index.php?$args;
Restart nginx server using the command.
sudo service nginx restart;
Step 4: Now turn on the caching.

That’s it. Now you have a fast loading site.


Leave a Reply