Title: Cloudflare Workers
Last modified: September 7, 2025

---

# Cloudflare Workers

 *  Resolved [diaphragm0714](https://wordpress.org/support/users/diaphragm0714/)
 * (@diaphragm0714)
 * [7 months ago](https://wordpress.org/support/topic/cloudflare-workers/)
 * Hello, I had a little question, and my question is:
    1. Woudl your plugin be compatible with cloudflare workers?
    2. When using your plugin + Litespeed cache it works so far, however i wanted to
       know if the browser cache option should be turned “on” in litespeed cache?
    3. Similiar to question 2, should the “cache” option be enabled in litespeed cache
 * Although there is no issues on my ends, i am just making sure double caching 
   function is avoided.
 * Here is my observation so far: On product pages first Visit CF dosent cache the
   page, but litespeed does (Compatibility success). Then on page reload or refresh
   CF cache HIT (Everything works normal).
 * Just wondering but no errors so far.

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [digitalpoint](https://wordpress.org/support/users/digitalpoint/)
 * (@digitalpoint)
 * [7 months ago](https://wordpress.org/support/topic/cloudflare-workers/#post-18631295)
    1. There isn’t anything that would make it automatically incompatible, but the 
       things you can do with Workers is basically limitless. If a Worker is doing 
       things like altering Cache Control headers, it certainly could interfere with
       parts of the plugin. Again, not inherently incompatible, but it really would
       depend on what the Worker was doing to the underlying HTTP request.
    2. This plugin handles things like browser cache already. It’s probably not a great
       idea to have two plugins trying to do the exact same thing, but it would *probably*
       be okay. Might be a little weird if you think one plugin is doing something 
       specific (like setting length of time for browser cache), then the other plugin
       sets it to something different. Handling it with multiple plugins isn’t going
       to make it better/faster or anything, only slightly slower (double the code 
       running) and possibly confusing when one plugin uses its settings when you expect
       the settings from the other one.
    3. I personally wouldn’t, but it would be specific to your site. It would make 
       sense to benchmark it and see if having what is effectively a cache for a cache
       makes your site faster or slower. This plugin avoids the request even going 
       to your origin server when it can (serves direct from Cloudflare data center
       closest to the user), so there may not be a ton of value in having a cache that
       resides on your origin server.
 * Yep, you are basically creating a cache for a cache. Seems like a lot of added
   complexity and potential for something to break for little upside. Maybe there
   are cases where a site gets a crazy amount of traffic (like thousands of page
   views per second) and a secondary cache that is automatically distributed to 
   multiple web servers and generated before requests are made for the pages or 
   something. I could see edge cases like that where it makes sense. But best thing
   to do is benchmark it and see if having a cache for a cache is beneficial for
   your site or not.
 *  Thread Starter [diaphragm0714](https://wordpress.org/support/users/diaphragm0714/)
 * (@diaphragm0714)
 * [7 months ago](https://wordpress.org/support/topic/cloudflare-workers/#post-18631312)
 * Hi, Thank you and great explanation.
 * I turned off browser cache in litespeed and i will test how it works, this means
   only your plugin will do browser cache and LS will do other cache.
 * I am trying to achieve this on workers, but i am not sure if i am right on this.
 *     ```wp-block-code
       See the code: // URLs to bypass cache completelyconst BYPASS_URL_PATTERNS = [/\/wp-admin\/.*/, // WordPress admin/\/wp-login\.php$/, // WordPress login/\/cart\/?.*/, // WooCommerce cart/\/checkout\/?.*/, // WooCommerce checkout/\/my-account\/?.*/, // WooCommerce account/\/robots\.txt$/, // robots.txt/\/wp-content\/.*/, // static assets/\/wp-includes\/.*/ // WordPress core assets];// Only cookies that truly change page contentconst PERSONALIZATION_COOKIES = ["wmc_current_currency","trp_language"];addEventListener("fetch", event => {event.respondWith(handleRequest(event.request));});async function handleRequest(request) {const url = new URL(request.url);// 1️⃣ Bypass cache for admin/cart/checkout/account pagesfor (const pattern of BYPASS_URL_PATTERNS) {if (url.pathname.match(pattern)) {return fetch(request);}}// 2️⃣ Parse cookiesconst cookieHeader = request.headers.get("cookie");let cookies = {};if (cookieHeader) {cookies = Object.fromEntries(cookieHeader.split(";").map(c => {const [k, v] = c.trim().split("=");return [k, v];}));}// 3️⃣ Only use currency + language for cache-bustinglet cacheBuster = [];for (const name of PERSONALIZATION_COOKIES) {if (cookies[name]) {cacheBuster.push(${name}=${cookies&#091;name]});}}if (cacheBuster.length) {url.searchParams.set("cf_cache_bust", cacheBuster.join("_"));}// 4️⃣ Create new request with modified URLconst newRequest = new Request(url.toString(), request);// 5️⃣ Fetch response from origin / LiteSpeedreturn fetch(newRequest);}
       ```
   
 * The main reason is for the wmc & trp cookies so as to ensure seperate currencies
   and languages are cached properly, this is why i left litespeed cache active 
   as it cache seperate cookies and languages.
 *  Plugin Author [digitalpoint](https://wordpress.org/support/users/digitalpoint/)
 * (@digitalpoint)
 * [7 months ago](https://wordpress.org/support/topic/cloudflare-workers/#post-18631360)
 * I haven’t tested that Worker code (I also don’t have LiteSpeed installed anywhere),
   but I don’t see anything in there that would interfere with this plugin.
 * If your Cloudflare zone is on a paid plan (anything except “Free”), you may want
   to look at [Snippets](https://dash.cloudflare.com/?to=/:account/:zone/rules/snippets).
   They are lightweight Workers that have no per request cost (Workers are free 
   for up to 100,000 requests/day, but there’s a cost after that). That’s fairly
   simple Worker code, so should work just fine as a Snippet.
 *  [ksaltik](https://wordpress.org/support/users/ksaltik/)
 * (@ksaltik)
 * [6 months, 2 weeks ago](https://wordpress.org/support/topic/cloudflare-workers/#post-18656922)
 * This can be done without Cloudflare Workers or even a Page Rule (done with a 
   single Cache Rule on Cloudflare’s side, and custom code in the plugin).
 * how your plugin cache the pages. Does it without cloudflare workers or kv workers
   I dont have much information.
 * can you explain it so we can understand how the plugşn works

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Cloudflare Workers’ is closed to new replies.

 * ![](https://ps.w.org/app-for-cf/assets/icon.svg?rev=2975357)
 * [App for Cloudflare®](https://wordpress.org/plugins/app-for-cf/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/app-for-cf/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/app-for-cf/)
 * [Active Topics](https://wordpress.org/support/plugin/app-for-cf/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/app-for-cf/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/app-for-cf/reviews/)

 * 4 replies
 * 3 participants
 * Last reply from: [ksaltik](https://wordpress.org/support/users/ksaltik/)
 * Last activity: [6 months, 2 weeks ago](https://wordpress.org/support/topic/cloudflare-workers/#post-18656922)
 * Status: resolved