Cleavr Cache not working

I am trying to enable server-side caching, but the cache doesn’t clear automatically. My site has a lot of custom post types. I assume that is the problem. Is there any way to enable cache to be cleared after ALL post types are updated?

I guess the best way of doing that is to use a WordPress Caching Plugin, as most of them can detect page or post modifications. Haven’t migrated my WordPress installs to cleavr atm but on my custom VPS the Plugin WP Rocket worked fine clearing also the fast cgi cache. I needed to do some modification though, which I don’t remember all, but I think googling “nginx fastcgi cache wp rocket” will give you the informations :smiley:

Edit: GitHub - SatelliteWP/rocket-nginx: Rocket-Nginx is a Nginx configuration that makes WP-Rocket even faster by serving static pages directly without loading WordPress or PHP. is what you need to do with WP Rocket. It is server-side caching, not the original fastcgi caching. However, it is similar from the performance as it delivers the static files without hitting PHP.

2 Likes

Hello @aay and @Jeazyee,

We’ve got a Cleavr Clear Cache Plugin for WordPress Cleavr Clear Cache – WordPress plugin | WordPress.org which allows you to clear site cache with the click of the button. You can also set it up to automatically clear cache when content on your site changes.

Otherwise, you can simply update the cache directive from your site. Go to Site > Cache > Tweak cache settings.

Thank you!

3 Likes

…delivers the static files without hitting PHP

I’v learned that in most cases this kind of caching isn’t used by WP rocket.
For example: at the moment you’re using a cookie message, WP rocket kan detect this and serves the cached files using PHP and not via the configuration in Nginx (or .htacces on other servers)
With Cleavr I use mostly the Nginx fastcgi cache and the mentioned plugin.

You need only the nginx config changes for browser caching and some others.
I never used the satelitWP/rocket-nginx “tool” because it makes no sense to install a package for some config changes. Check their code and add them by yourself :wink:

2 Likes

@EineeshGelal Awesome that there is a WP plugin from cleavr for the fastcgi cache! :heart_eyes: Will try it out asap! :+1:

@finalwebsites The SatteliteWP nginx config “tool” worked fine for me as it was very convenient, especially for those (including me) who are not that experienced with nginx configs :upside_down_face:

3 Likes

Oh, I was talking about the plugin itself. Whenever an update is made on a page, post, CPT, it doesn’t clear the cache. I have to manually clear the cache every time, a little annoying if you ask me.

You say this option isn’t working?

ZB_Selection_238

Yep, it doesn’t work

Hello @aay,

Can you confirm that you’ve enabled Cache for your site? Also can you please verify that the hook URL is correct? You can enable Cache by visiting Site < Cache.

Hello @aay,
I tested out the plugin to make sure it’s working as expected and it looks to be working for me.

Per @finalwebsites screenshot above, just need to add the Clear Cache Trigger hook, which is located in cleavr > site > cache .

The FastCGI cache is located at /opt/cleavr/nginx/<site name> on the server. You’ll see cache folders that are named with a single character, like in the image below. Once Clear Cache is hit, either via the button or if a new post is added when the checkbox is checked, then the cache folders will be removed.

With cache folder:

After cache cleared:

I hope that explains a little how the plugin works and what to expect. Please let us know if there is something else that appears to be not working as expected.

It’s been a while since we’ve last worked on the plugin and I’d love to get ideas on how we might enhance it.

1 Like

I have some ideas:

  • Cache pre-loading (based on the sitemap?)
  • Clear cache for a single post (using the hook you mentioned in your reply)
  • Exclude pages/posts (I know you can do this via Cleavr, but for most users it would be easier using a option page in WordPress)
  • A field where the user can enter the time before a cache file invalidates.

I remember me some concerns about the time it takes whenever the cache is cleared after saving a post. This is an issue for sure. An option would be to call a wp cron event that removes the cache in the background after X minutes. This solves also the problem that the cache is removed every time I hit the save button.

I know excluding posts for caching via the WP dahboard is a problem, but maybe you can add a header to this pages? The header could be used a filter in nginx config, right?

3 Likes

What I would like to see is a public GitHub repo for the WP Plugin. And a functionality for clearing the cache over WP CLI like:

wp cleavr-cache clear all
1 Like

Why do you need a WP CLI function? The cache invalidates every hour…

1 Like

@finalwebsites It’s about automation. I have created a tool for updating my wp installs, that includes visual testing with percy. So I need the cache to be cleared after deployment of updates. However, for my use case it is not needed as I can fire the webhook on deployment. But maybe some other use cases require this feature, especially non-bedrock users. It would still be possible to fire the webhook directly though but in my opinion not as convenient as using WP CLI.

I know that this is not exactly like having a WP CLI function (and, arguably, not as conveninent) but once you have the clear cache hook in Cleavr, you can simply run a curl command to clear cache from terminal:

curl -X POST <CACHE_CLEAR_HOOK_FROM_CLEAVR>

1 Like

I know, but it’s still one more step (after wp plugin update --all) you need to have the individual hook URL each time you update a wp site. But perhaps I am just too lazy :laughing:

I think people using WP CLI are the same type of users which are able to fire the webhook :wink:

That makes sense. I’m not a fan of “blind” updates, but I know there are many users running updates this way on a great scale. Is it maybe an option to get the webhook URL right from the options table (I guess the URL is stored there)?