Not sure how to make it work with Worker
-
I am on the Business plan and it should simply rely on .cookies bypassing instead forcefully adding query string.. and it allows to disable with Worker but not sure how to make it work. Is there any documentation?
I have enabled worker option, and I can’t seem to purge cache automatically when I update any post.
-
Hi @thegulshankumar,
I didn’t understand your full question. The Worker mode works perfectly I use it on many of our sites. There is no need to deploy the worker, you can keep it in the undeployed mode. The worker will still work fine. Can you enable the log mode inside the plugin settings and update the post and then see the outputs in the log?
In fact, you can even overwrite the default worker code provided by the plugin if you want to and know what you are doing. Check the FAQ section in the plugin settings for more details on this matter.Thanks @isaumya for your response.
Here are clear details –
Topic Title: Automatic purge doesn’t trigger after Post update when using Worker mode.
Step 0. I clicked ‘Reset’ and did the setup of Global API, Email and site.
Step 1. I enabled worker mode > Clicked Update Settings button at the bottom
Step 2. I enabled Page caching, as asked my plugin, returns a message ‘Page cache enabled successfully’
Step 3. Using the Block Editor, I updated my post, adding an emoji in Title.
Step 4. After waiting some time.
Step 5. I opened Guest Window of Chrome, I didn’t see the updated content.
In the HTTP response of HTML Doc, the value of ‘Age’ keep increasing than the previous number.
Clearly, Purge was not triggered. I could repro this every time.
Step 6. Then, here’s my log. (Redacted some PI).
Ref: https://gist.github.com/thegulshankumar/ff0a81f261676910a01dea70973dee35
I am no aware why it says “workers.api.error.script_not_found” at line: 51I wish to use the ‘Worker’ method to avoid query parameter for the logged-in case. If it would work it would be helpful.
Thanks & Regards,
GulshanHi @thegulshankumar ,
in order to increase the performance while logged in, the cache is not purged in real time but via a scheduled event after 10 seconds, using the native WordPress function wp_schedule_event that is fired on “shutdown” WordPress action.Reading your logs, seems that the event didn’t start.
Can you please check if into the directory wp-content/wp-cloudflare-super-page-cache/YOUR_DOMAIN/ there is the file purge_cache_queue/cache_queue.php ?
<?php $swcfpc_cache_queue='{\"purge_all\":false,\"urls\":[\"https:\\/\\/www.example.com\\/category\\/REDACTED\\/\",\"https:\\/\\/www.example.com\\/category\\/REDACTED\\/page\\/2\\/\",\"https:\\/\\/www.example.com\\/author\\/gulshankumar\\/\",\"https:\\/\\/www.example.com\\/author\\/gulshankumar\\/feed\\/\",\"https:\\/\\/www.example.com\",\"https:\\/\\/www.example.com?feed=rss2\",\"https:\\/\\/www.example.com\\/REDACTED\\/\",\"https:\\/\\/www.example.com\\/\"]}'; ?>
After digging further, I discovered the external Cron Job which I had set up via CF Worker was not triggering at all.
To fix, I reverted to default WP style, then plugin quickly cleared CF Cache.
Thanks for your assistance. This topic can be marked as resolved.
Hi @thegulshankumar,
What issues did you faced using the CF worker based cron job. I have also set up WordPress Cron via CF worker in one of my client site and haven’t seen any issue as of yet.Cloudflare worker past event log said –
* * * * * Thu, 01 Oct 2020 17:11:32 0.142 Success * * * * * Thu, 01 Oct 2020 17:10:32 0.115 Success * * * * * Thu, 01 Oct 2020 17:09:32 0.209 Success * * * * * Thu, 01 Oct 2020 17:08:32 0.156 Success * * * * * Thu, 01 Oct 2020 17:07:32 0.133 Success ...
Still, couldn’t publish schedule ‘Page’ on time
Sadly, I switched back to psuedo-cron what by default comes in WordPress. And all things started working normally.
I would be happy to know why CF worker approach did not worked for me. I’ll possibly let you know as I find.
Conflict with Worker based Cron + WP Cloudflare Super Page Cache (Worker mode)
—————————
List of associated issues
—————————
#1. Missed Schedule Error
#2. Can’t trigger automatic purge on ‘Post update’ eventList of active plugins
————————Comment Reply Email Notification Version 1.12.0 by Arno Welzel | Auto-updates disabled Elementor Version 3.0.11 by Elementor.com | Auto-updates disabled Elementor Pro Version 3.0.5 by Elementor.com | Auto-updates disabled Flying Analytics Version 1.1.3 by Gijo Varghese | Auto-updates disabled GP Premium Version 1.12.1 by Tom Usborne | Auto-updates disabled Hide Related Video Youtube Version 1.0 by Trần Hoàng Quốc. | Auto-updates disabled Rank Math SEO Version 1.0.48.2 by Rank Math | Auto-updates disabled SVG Support Version 2.3.18 by Benbodhi | Auto-updates disabled Theme Functions Version 1.0 by Gulshan Kumar | Auto-updates disabled UpdraftPlus - Backup/Restore Version 1.16.29 by UpdraftPlus.Com, DavidAnderson | Auto-updates disabled WP Cloudflare Super Page Cache Version 4.3.6 by Salvatore Fresta | Auto-updates disabled WP File Manager Version 6.9 by mndpsingh287 | Auto-updates disabled
Testing Stack: LAMP
Steps to Repro Missed Schedule Error
—————————- Part 1 Using external Cron Job —
Step 0. Add below constant in the wp-config.php file just above a famous comment line – /* That’s all, stop editing! Happy publishing. */
define('DISABLE_WP_CRON', true);
Step 1. Enable Cron Job via Worker successfully for ‘Every 1 minute’. Already done? Skip to part 2.
https://wpspeedmatters.com/cron-jobs-using-cron-triggers/Step 2. Schedule publishing of 10 pages ‘Without WCSPC 1’, ‘Without WCSPC 2’… ‘Without WCSPC 10’ for next 10 mins
Step 3. Do not activate “WP Cloudflare Super Page Cache”
Step 4. Your Scheduled post will be published smoothly. In case missed, WP will carry forward and publish.
—– Part 2 ——
Step 5. Activate the ‘WP Cloudflare Super Page Cache’ with Worker mode and Disable the cache buster (otherwise, issue cant be repro)
Step 6. Schedule publishing of 10 pages ‘With WCSPC 1’, ‘With WCSPC 2’… ‘With WCSPC 10’ for next 10 mins
Step 7. Have some coffee meanwhile 🙂
Step 8. On return you will be shocked to see “Missing Scheduled” error message from WordPress. Check back after 10 min. Same.
Step 9. To fix Missing Scheduled error, deactivate WP Cloudflare Super Page Cache and wait another minute for cron job.
Step 10. Result: Missing Scheduled will be gone. Scheduled Post published automatically.
Steps to Rerpo Cache not purging on common event
————————————————-* Update any post
* In public/wp-content/wp-cloudflare-super-page-cache/www.example.com/purge_cache_queue/cache_queue.php you will see<?php $swcfpc_cache_queue='{\"purge_all\":false,\"urls\":[\"https:\\/\\/www.example.com\\/author\\/john\\/\",\"https:\\/\\/www.example.com\\/author\\/john\\/feed\\/\",\"https:\\/\\/www.example.com\\/cron-enabled-cache\\/\",\"https:\\/\\/www.example.com\\/\",\"https:\\/\\/www.example.com\\/cron-enabled-cache__trashed\\/\",\"https:\\/\\/www.example.com\\/cron-enabled-cache\\/feed\\/\",\"https:\\/\\/www.example.com\\/cron-test-11212121\\/\",\"https:\\/\\/www.example.com\\/cron-test-11212121__trashed\\/\",\"https:\\/\\/www.example.com\\/cron-test-11212121\\/feed\\/\",\"https:\\/\\/www.example.com\\/category\\/wordpress\\/\",\"https:\\/\\/www.example.com\\/category\\/your-category\\/page\\/2\\/\",\"https:\\/\\/www.example.com\",\"https:\\/\\/www.example.com?feed=rss2\",\"https:\\/\\/www.example.com\\/your-permalink\\/\"]}'; ?>
* but post wont purge, age keep increasing.
When I access /wp-cron.php?doing_wp_cron directly in Chrome, then …
The Missing Scheduled is gone, and again published successfully.
But …
The age which was 3XX and now is 6XX. Purge by ‘WP Cloudflare Super Page Cache’ didn’t triggered.
Another round of test
————————–1. Deleted trigger in CF worker
2. Enabled cron manually via crontab* * * * * * cd /var/www/example.com/public; php wp-cron.php &>/dev/null
3. Updated my ‘Post’
4. After waiting 2 minutes, no update found. Again, purge didn’t triggered.
5. Added few scheduled post to test if cron is working or not….
6. This time, Missing Scheduled appeared for few seconds but quickly gone.Conclusion
—————-1. In this entire test, not a single time purge was triggered in Worker mode for ‘post update’.
2. The Missing Scheduled issue happened with CF worker based cron job and in presence of ‘WP Cloudflare Super Page Cache’
3. I failed to repro ‘Missing Scheduled’ issue in case on real crontab setup.
4. If I switch to another theme, ‘purge everything’ is triggered regardless of any crontab mode.
5. In worker mode I update post while having commented out// define('DISABLE_WP_CRON', true);
, still purge doesn’t trigger.
5. If I don’t use worker mode and I update post while having manual cron anddefine('DISABLE_WP_CRON', true);
purge trigger.- This reply was modified 3 years, 6 months ago by Gulshan Kumar. Reason: code beautified
- This reply was modified 3 years, 6 months ago by Steven Stern (sterndata).
I have dig into detail and found some interesting info
https://gist.github.com/thegulshankumar/474ae7baee8922eecdf60ab75284e700Hi @thegulshankumar,
Thanks a lot for reporting this issue. I’ll see what might be causing the auto-purge not getting triggered. But the thing that I’m most confused with is why the Worker Based corn jobs are not working when using the CF Worker Mode in the plugin.Our worker is associated with a route whereas a Cron worker is not associated with a route and instead associated with a trigger. This is very wired indeed.
Just to ask, so if you disable the worker mode inside the plugin and use the page rule mode for caching, does the CF Worker based Cron work then? Cause if you disable the worker mode in the plugin then it uses the CF page rules and has no interaction with Workers. Let me tag @salvatorefresta as well here.
- The topic ‘Not sure how to make it work with Worker’ is closed to new replies.