Issue Enabling Worker Mode & Using SWCFPC_CF_WORKER_FULL_PATH
-
I’m trying to use your plugin’s Worker Mode with a custom Worker script to implement advanced multi-currency caching at the Cloudflare edge for my WooCommerce site.
I have followed the FAQ guidance and defined the SWCFPC_CF_WORKER_FULL_PATH constant in my wp-config.php file, pointing to the absolute server path of my merged custom Worker script (which combines your worker_template.js logic with my necessary modifications for varying the cache key based on CF-IPCountry and a currency-specific cookie).
Example: define(‘SWCFPC_CF_WORKER_FULL_PATH’, ‘/home/662214.cloudwaysapps.com/chyneruzzn/public_html/wp-content/my-custom-worker.js’);The Problem:
Despite having the constant correctly defined (with WORKER, not WOKER), the plugin does not appear to be deploying my custom Worker, nor its own default Worker. My Cloudflare dashboard (Workers & Pages for minoar.com) shows no Worker service deployed by your plugin. The plugin’s internal logs consistently show it managing/updating a Cloudflare Cache Rule, indicating it’s operating in a Cache Rule mode, not Worker mode.Troubleshooting Steps Taken & Findings:
- Initial Typo in Plugin Code: Using Query Monitor, I initially found a warning: Warning: Undefined array key “swcfpc_cf_woker_enabled” in …/wp-cloudflare-page-cache/libs/backend.class.php:342. I manually corrected this typo (and others found via string search) from woker to worker in the plugin’s PHP files.
- New Warning After Fix: After correcting the typo in the PHP files and re-saving plugin settings, the Query Monitor warning changed to: Warning: Undefined array key “swcfpc_cf_worker_enabled” (now with the correct spelling) at the same location. This suggests the plugin is now looking for the correctly spelled option, but this option is not being properly initialized or saved in the WordPress database via the plugin’s UI.
- No UI Option for Worker Mode: I have thoroughly checked all tabs and settings within the plugin (including “Advanced Settings” and the initial Cloudflare API connection tab). I cannot find an explicit UI toggle or selection to switch between “Page Rule Mode” and “Worker Mode.” The main “Enable Cloudflare CDN & Caching” toggle (which mentions “using Cache Rule” in its description) does not seem to trigger Worker deployment even after the PHP typo fixes and with the wp-config.php constant set.
- Overwrite cache-control header… Setting: I have ensured the setting “Overwrite the cache-control header for WordPress’s pages using web server rules” is set to NO (Disabled), as its description states it “must be disabled if enabled the Workers mode option.”
- API Connection: The plugin is successfully connected to my Cloudflare account (using both Global API Key and a correctly permissioned API Token for testing) and correctly identifies my minoar.com zone. It can purge cache successfully.
My Questions:
- How can I definitively enable/trigger Worker Mode within the plugin so that it attempts to deploy a Worker and respects the SWCFPC_CF_WORKER_FULL_PATH constant for using a custom script? Is there a hidden setting, a specific sequence of actions, or a known issue with the UI for selecting Worker Mode?
- Given the “Undefined array key swcfpc_cf_worker_enabled” warning (after fixing the woker typo in your PHP), how can I ensure this option is correctly saved to the database so the plugin recognizes that Worker Mode is intended/enabled?
I believe the core issue might be related to how the swcfpc_cf_worker_enabled option is set or read internally, preventing the plugin from switching to Worker Mode and utilizing the custom worker path.
Any guidance you can provide would be greatly appreciated. I’m keen to use the Worker functionality for my site’s specific caching needs.
Thank you!
The topic ‘Issue Enabling Worker Mode & Using SWCFPC_CF_WORKER_FULL_PATH’ is closed to new replies.