WordPress Nginx Cache Plugin

If you are running WordPress on apache, you have no problem because all the well-known cache plugins like Quick Cache, WP Super Cache & W3 Total Cache work very well.

However, if you are running WordPress on nginx, then you have a problem because with the different rewrite rules that Nginx has, the cache plugins do not work well. You can try all the popular plugins, Quick Cache, WP Super Cache & W3 Total Cache. If you look at the “source” of the index.php, you will see that a cached page has been delivered. However, if you look at the source of the single.php, you will find that it has not been cached.

One solution for this is the nginx Compatibility plugin which I explained here. I’ve got it working on this site without any problem. However, I’ve not had the same luck on my other sites running nginx. Even with the nginx Compatibility plugin, the single.php pages are not being cached.

Well, the solution may be the DB Cache Reloaded Fix plugin.

I’ve tried it over all my sites running nginx on Centos & Ubuntu and it works very well.

How to test that the cache plugin is working:

The best solution is this:

(i) install a download manager like wp-downloadmanager or “WordPress Download Manager”;

(ii) Upload a file and embed it into a post through the download manager;

(iii) From another browser (so that you are not shown as a logged-in user), access the post and click on the download link and then refresh the page. You will see that the download counter increases to show the number of downloads;

(iv) Now install the DB Cache Reloaded Fix plugin and try the same exercise. You will see that the download counter does not increase. This is proof that you are being served a static page and not a dynamic one.

A couple of noteworthy points about the plugin are:

(i) You can choose the number of minutes for which the pages are cached. I chose 1440 minutes (24 hours);

(ii) When you approve a comment or a pre-approved comment author’s comment is published, the entire cache is automatically cleared.

(iii) The footer in the source page shows the number of queries that were made to the database and how many are cached. When you start, all the queries are from the database. When you refresh a couple of times, almost all the queries are delivered from the cache and not from the database.

1 thought on “WordPress Nginx Cache Plugin

  • […] to duplicate this at my other sites, I didn’t have the same luck. So check the post on the DB Cache Reloaded Fix plugin which appears to work very well with nginx (tested with Centos & Ubuntu). RELATED […]

Leave a Reply

Your email address will not be published. Required fields are marked *