fastcgi_cache + Wordpress random post plugin

Hello,

When using https://wordpress.org/plugins/wp-random-post/ with fastcgi_cache on, on my test site http://ee.leiko.dy.fi/random/ it always returns the same post. This plugin is supposed to give redirect to random post, and ofc works ok without any caching. Any suggestions how to make this work with fastcgi_cache on, or maybe some other plugin that somehow magically works with fastcgi_cache on?

Hi, As you are using fastcgi cache, it will cache your complete page. I have fear that this plugin will not work with caching mechanism. You need to disable fastcgi_cache for that.

@sitkonen you don’t need to disable fastcgi_cache

Just edit /etc/nginx/common/wpfc.conf file and add URL’s you want caching be skipped to line: https://github.com/rtCamp/easyengine/blob/master/config/nginx/common/wpfc.conf#L16

So line:

if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|wp-.*.php|index.php|/feed/|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {

will become something like:

if ($request_uri ~* "(/random/|/wp-admin/|/xmlrpc.php|wp-.*.php|index.php|/feed/|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {

Note /random/ added to skip URL list.

After you save changes, run nginx -t && service nginx reload to test new config and reload if there are no errors.

This works, thanks. I also had to add /random/ to w3tc database cache’s “Never cache the following pages:” list.

Hello @sitkonen,

Glad to know your query is resolved.

I am closing this support topic for now. Feel free to create a new support topic if you have any queries further. :slight_smile: