-
-
Notifications
You must be signed in to change notification settings - Fork 8
Using the Worker on multiple WordPress
Norbert Boros edited this page Sep 22, 2023
·
1 revision
If you manage multiple WordPress sites, say 50 or even 100+, deploying a separate Worker for each can be cumbersome.
A more efficient approach is to utilize a single Worker and establish triggers for each domain. This not only streamlines the process but also simplifies maintenance.
Starting from version 2.0.0, I've introduced site-specific configurations. This allows you to tailor the settings for each domain that routes through the Worker.
For instance:
const SITES_CONFIG = [
{
DOMAIN: 'www.website.com',
REWRITE_LINK_TAGS: true,
REWRITE_STYLE_TAGS: true,
REWRITE_IMAGE_TAGS: true,
REWRITE_HREF_TAGS: true,
REWRITE_DIV_TAGS: true,
REWRITE_SVG_TAGS: true,
IMAGE_LAZY_LOAD: true,
IMAGE_QUALITY: 90,
IMAGE_FIT: 'crop',
IMAGE_GRAVITY: 'auto',
IMAGE_SHARPEN: 1,
IMAGE_METADATA: 'none',
},
// Add more as needed
];
I opted for constants because, occasionally, the environment variables don't load reliably. Regrettably, this means you'll have to make some manual edits.
NOTE: The domain specified here must match with the trigger you set to the Worker routes.