Auto-cache cron jobs

Good afternoon,

I have CC Pro and a site that does a lot of imports at night.

The AutoCache’s 15 minutes cron job interferes however with these imports causing problems.

Let’s say my imports finish at 8 AM. Then what I would like to do is the following (with autocache enabled)

  • delete the associated autocache the cron job so it doesn’t run every 15 minutes
  • after my imports run a cron job to delete all cached files
  • after that run a cron job to run autocache (once a day)

I’ve tried to achieve this with WP Crontrol but without any luck so far. Could not modify or delete your CC cron jobs. Do you know why?

Can you help me achieve this?

Thanks,
Olaf

The problem almost certainly isn’t with Comet Cache but with WP’s silly cron function. This post explains the problems with it and how to set up a real cronjob that should do what you need: https://tommcfarlin.com/wordpress-cron-jobs/

OK but can you help me with this.

I have a cron job to run the auto-cache like so:
/usr/bin/curl http://example.com/?comet_cache_auto_cache_cron=1 -so /dev/null

Is there an equivalent to clear the cache?

Greets,
Olaf

See this: https://cometcache.com/kb-article/clearing-the-cache-dynamically/

Hi Tim,

Thanks but I don’t see what I’m looking for.

I want to do the following:

delete the CC auto-cache engine 15 minutes cron job
enter my own daily cron job via my hosts linux command

So how can I do both? I don’t see a command line cron job example in the link you sent me. or am I missing something?

Thx.

and the daily job in this case is the clear cache job, I already have the auto-cache cron in place

So are you saying that you werre always running Comet Cache’s auto-cache function via a true cronjob? If so, then I can’t help you.

You will need to Google for more expert help on setting up more complex cron patterns. Stack Exchange/Overflow usually does the trick.

No I was just doing that just because I couldn’t change the 15 minutes interval. If that would be possible in CC then there would be no problem at all.

But since that seems not to be possible for some reason, I am now trying to circumvent the problem of interfering with my daily imports by two things:

  1. Clearing the cache every day at 8. So for this I need a cron job command line

  2. Running the auto-cache every day at 8.15 from my own cron with /usr/bin/curl http://example.com/?comet_cache_auto_cache_cron=1 -so /dev/null

Does that make things more clear?

Greets,
Olaf

Honestly, I doubt you need to bother with (1). If the real cron does its job, my guess it will all work fine.

Hi Tim,

I would really like to just use the regular real Cron jobs of Comet cache, however I have seen that the AutoCache feature seems to interfere with the imports I’m doing during the night.

So maybe you can help me out: what I’m trying to achieve is the following. The imports last from 12 PM until 8 AM. After that I want a fresh cash, obviously because all the items have been renewed and updated during the night. But I don’t want to AutoCache feature to run between 12 PM and 8 AM, because everything gets renewed and updated so it does make sense, and it will stress the servers.

How would you recommend to tackle this then?

Greets, Olaf

My suggestion is to do just what I suggested at the start. Follow McFarlin’s article and do what he suggests. Then let it run and see if it all works.

Hi Tim,

That solution is just not a workable one. My site uses over 18 Cron jobs regulated by WP Cron. So to disable WP Cron and rebuild it all manually is not only huge task, but also for maintenance point of view not preferable.

Maybe I have a workaround but then you might help you with this one. Whenever I change the setting involving a Cron job in Comet cache, will that then the active from that moment on.

What I mean is this: if for example I change the cache cleanup schedule to one day at 9 PM, does that mean that 9 PM will be the exact hour the schedule will be executed every day from that point onward?

In that case I could set the cache cleanup schedule to one day at the time of my liking and then I can just use the regular settings.

Only one thing remaining then is to disable the auto cache engine in WP Cron. Could you help me with that because I cannot get it deleted for some reason through WP Crontrol.

Greets,
Olaf

It would mean that if you use a real cron, but not if you’re using WP Cron. That’s the whole point. WP Cron will only run if someone visits your site and, if that doesn’t happen within a certain period of the set time, it seems to “forget” the cronjob altogether. So, unless you can guarantee traffic to your site just after 9pm, you have no idea whether the cron will even run at all.

You must disable the auto-cache engine from within Comet Cache. If you try doing it from within WP Crontrol, it will just reset itself.

So would you recommend a solution like this: http://a32.me/2012/10/why-wordpress-cron-fails-and-how-to-fix/

That would fix the no visitor problem. And then if I would change the Cleanup setting at 9 AM it would rerun the next morning at 9 AM, no?

That’s precisely what I suggested when I referred you to the first article!

Okay, from that article I understood that (bear in mind I am not a developer :wink: ) you had then also to rebuild every cron job manually.

But good to hear it’s easier than that. Thanks again for your patience.

But just one more question regarding this: when I disable Auto-Cache from within CC will the cron comet_cache_auto_cache_cron=1 still work?

No. And I don’t suggest you do it. All I’ve ever suggested was that you set up a real cron job to replace WP Cron. It might not work. (I don’t know you site or setup.) But the first thing to try is always something simple, and then see what happens.

If you change several things at once and it still doesn’t work, you will be working with too many variables.

Will do and let you know if I run into trouble.

Thx.