Hello @georgepennet
Thank you for reaching out and I am happy to assist you with this
To reliably schedule something – you should use Unix cron. Depending on a server and on the yoru control panel, you should just run a script from cron each X hours.
I hope this helps!
Thanks!
I’ve noticed that there is a option on Page cache -> purge policy.
What will happened if I’ll set Purge limit to 0? If I’m not mistaken this should purge all cache once new post will be published.
I also wanted to add few additional pages to be purged once the post is published but I’m not sure in what format. Full url like: https://mydomain.com/test2/
or maybe just /test2/ ?
This will work when most of my articles are scheduled?
I set a cron on my server to run this
/usr/local/bin/php /home/admin/domains/mydomain.com/public_html/wp-content/plugins/w3-total-cache/w3-total-cache-api.php
Doesn’t seems to be doing anything…
Hello @georgepennet
Thank you for your feedback.
The Purge Policy options are self-explanatory.
For example, if you have enabled
Front page
Posts page
Post page
Blog feed
Once any page is updated, or a new post added, the cache will be automatically purged for all above as you can see in the description Specify the pages and feeds to purge when posts are created, edited, or comments posted
When the Purge limit is set to 0 it means that all pages that list posts are purged:
/page-2/
/page-3/
/page-4/
/page-5/
etc.
Yes, you only need to add /test2/ to additional pages, however, the Purge policy should take care of that. Additional pages can be used for the custom post types.
As for the cron, you need to call the function $w3_plugin_totalcache->flush_all();
I would advise reaching out to your hosting provider to set a cron and call the Flush.
Also, the Purge Policy should take care of everything once any article/post is updated or created so there should be no need for cron.
Thanks!
Thank you. But hm..My provider won’t tell me how to call that function :). I can set it up in direct admin but I have no clue what command I should use. I gave you an example how my current command looks like
/usr/local/bin/php /home/admin/domains/mydomain.com/public_html/wp-content/plugins/w3-total-cache/w3-total-cache-api.php
I would be grateful if you could show me how this command look like.
Hello @georgepennet
Thank you for your feedback.
Can you please share what your entire cron looks like?
Thanks!
I already showed you twice. This is what I added to the command field in DirectAdmin Panel for CronJob. Every 32 minutes:
/usr/local/bin/php /home/admin/domains/mydomain.com/public_html/wp-content/plugins/w3-total-cache/w3-total-cache-api.php
I can log via ssh so you can tell me how command should look like there.
-
This reply was modified 4 years, 3 months ago by
georgepennet.
-
This reply was modified 4 years, 3 months ago by
georgepennet.
Hello @georgepennet
You can configure a cron job to call wp w3-total-cache flush all using WP-CLI. For example:
*/15 * * * * cd ~/public_html/; wp w3-total-cache flush all &>/dev/null
… would flush all cache every 15 minutes. The &>/dev/null part discards all output (STDIN and STDERR).
You can add a line at the top of crontab MAILTO=”” to disable all email from cron job runs.
Email is only sent if something sends to STDIN or STDERR.
Alternatively, you can write a PHP script in a public directory and call it with curl.
for example:
create flush.php
<?php
require 'wp-load.php';
$f = CacheFlush_Locally();
$f->flush_all();
or
<?php
require 'wp-load.php';
w3tc_flush_all();
Call with one of the crons below, lat one being the best for your use case
0 0 * * * cd ~/public_html/; php -qf flush.php &>/dev/null
0 0 * * * curl -sk https://DOMAIN/flush.php &>/dev/null
0 0 * * * wget https://DOMAIN/flush.php -O /dev/null &>/dev/null
Thanks!