• Resolved Nate

    (@goseongguy)


    Hello,

    I have been very glad to use this plugin (on https://goseongguy.com/).

    I’ve been using Worker Mode. The Test Cache always fails, but I’ve been ignoring that because I can see cf-cache-status HIT on the root HTML document.

    But, these days I’m wondering if there really is no issue? When I do Test Cache, it says:

    “Page caching seems not working for both dynamic and static pages.
    Error on dynamic page (https://goseongguy.com): Unable to find the X-WP-CF-Super-Cache-Worker-Status response header. Worker mode seems not working correctly.
    Error on static resource (https://goseongguy.com/wp-content/plugins/wp-cloudflare-page-cache/assets/testcache.html): Unable to find the Cache-Control response header.”

    So I guess my question is: Is it OK that I don’t have the X-WP-CF-Super-Cache-Worker-Status response header for Worker Mode? Does this mean the plugin is not actually using Worker Mode?
    If this header is necessary for Worker Mode, do you have any guide or things to investigate about why that is missing?

    Cheers,
    Nate

Viewing 15 replies - 1 through 15 (of 23 total)
  • Plugin Contributor iSaumya

    (@isaumya)

    Hi,
    I can confirm that the Cloudflare caching is working on your site but I am not sure if it is using the worker mode. As when you have Worker Mode enabled, you will definitely get the X-WP-CF-Super-Cache-Worker-Status in the response header which is currently not there for your site which has lead me to believe that the worker mode is not working.

    Please check inside the plugin settings Worker Mode is enabled and then you update the plugin settings. Then Click on Disable Page Cache and then Enable Page Cache. After that check in your CF dashboard.

    Now under the page rule section there should not be any Cache Everything page rule there as the plugin si using the worker mode. Also under the worker section you should see an worker has been added by the plugin house route is set to https://goseongguy.com/*

    Please check these things.

    Thread Starter Nate

    (@goseongguy)

    Thank you for confirming. I have tried updating the settings, disabling the page cache and enabling, a few times. The issue is the same.

    In my Cloudflare account, I have no page rules active. There are 3 old ones but they’ve been disabled a long time ago.
    And I do see the worker route https://goseongguy.com/* show up in the Cloudflare dashboard when page caching is active.

    I have some snippets in my .htaccess for things like a few security headers, blocking all wp-includes folders and files, block external POST, blocks some XSS attacks, etc. Could this be a potential issue? I can share the .htaccess snippets if it would be helpful. I tried removing the custom .htaccess code but it doesn’t seem to affect the issue.

    Otherwise, what else can we look into?

    Plugin Contributor iSaumya

    (@isaumya)

    Hi, those htaccess security headers should not cause any issue. As that header mentioned above is getting added by the worker. Have you made sure that the worker mode is enabled on the site and there is no other worker in your CF dashboard than the one added by this plugin? I also see a x-nginx-cache being present on your site, better to disable that as well.

    Thread Starter Nate

    (@goseongguy)

    Have you made sure that the worker mode is enabled on the site

    I’m not sure what you mean, but Worker Mode is enabled in the plugin settings.

    There is no other worker present in the CF dashboard.

    The x-nginx-cache header has been removed.

    Is there any other info I can provide? Here is the log (high verbosity) from when I disable page caching to enable it.

    For some reason I sometimes I see the log mention WP_CACHE not being found, but it’s there in wp-config.php.

    [2022-04-05 04:57:05] [cloudflare::cloudflare_get_browser_cache_ttl] Request https://api.cloudflare.com/client/v4/zones/83fce0d845bc43b75874f930809eb136/settings/browser_cache_ttl
    [2022-04-05 04:57:06] [cloudflare::cloudflare_get_browser_cache_ttl] Response {"result":{"id":"browser_cache_ttl","value":0,"modified_on":"2021-04-24T15:30:29.469221Z","editable":true},"success":true,"errors":[],"messages":[]}
    [2022-04-05 04:57:06] [cloudflare::cloudflare_set_browser_cache_ttl] Request URL: https://api.cloudflare.com/client/v4/zones/83fce0d845bc43b75874f930809eb136/settings/browser_cache_ttl
    [2022-04-05 04:57:06] [cloudflare::cloudflare_set_browser_cache_ttl] Request body: {"value":0}
    [2022-04-05 04:57:06] [cloudflare::cloudflare_set_browser_cache_ttl] Response: {"result":{"id":"browser_cache_ttl","value":0,"modified_on":"2021-04-24T15:30:29.469221Z","editable":true},"success":true,"errors":[],"messages":[]}
    [2022-04-05 04:57:06] [cloudflare::worker_route_get_list] Request https://api.cloudflare.com/client/v4/zones/83fce0d845bc43b75874f930809eb136/workers/routes
    [2022-04-05 04:57:06] [cloudflare::worker_route_get_list] Response {
      "result": [],
      "success": true,
      "errors": [],
      "messages": []
    }
    
    [2022-04-05 04:57:06] [cloudflare::get_account_ids] Request https://api.cloudflare.com/client/v4/accounts?page=1&per_page=20&direction=desc
    [2022-04-05 04:57:06] [cloudflare::get_account_ids] Response: {"result":[{"id":"83e44cf10b74dd1d19a4513ad00416ba","name":"[email protected]'s Account","type":"standard","settings":{"enforce_twofactor":false,"access_approval_expiry":null,"use_account_custom_ns_by_default":false},"legacy_flags":{"enterprise_zone_quota":{"maximum":0,"current":0,"available":0}},"created_on":"2020-09-20T08:38:24.556084Z"}],"result_info":{"page":1,"per_page":20,"total_pages":1,"count":1,"total_count":1},"success":true,"errors":[],"messages":[]}
    [2022-04-05 04:57:06] [cloudflare::worker_get_list] I'm using the account ID: 83e44cf10b74dd1d19a4513ad00416ba
    [2022-04-05 04:57:06] [cloudflare::worker_get_list] Request https://api.cloudflare.com/client/v4/accounts/83e44cf10b74dd1d19a4513ad00416ba/workers/scripts
    [2022-04-05 04:57:07] [cloudflare::worker_get_list] Response: {
      "result": [],
      "success": true,
      "errors": [],
      "messages": []
    }
    
    [2022-04-05 04:57:07] [cloudflare::worker_upload] I'm using the account ID: 83e44cf10b74dd1d19a4513ad00416ba
    [2022-04-05 04:57:07] [cloudflare::worker_upload] Request https://api.cloudflare.com/client/v4/accounts/83e44cf10b74dd1d19a4513ad00416ba/workers/scripts/swcfpc_worker_1619093168
    [2022-04-05 04:57:07] [cloudflare::worker_upload] Response: {
      "result": {
        "id": "swcfpc_worker_1619093168",
        "etag": "bf5cf3b58a85fc1f7f372b4ccf37cb65825df7283121ef02bfdeb5a913639ea2",
        "handlers": [
          "fetch"
        ],
        "modified_on": "2022-04-05T04:57:07.429512Z",
        "created_on": "2022-04-05T04:57:07.429512Z",
        "usage_model": "bundled",
        "script": "// Worker version: 2.7.1\n// Default cookie prefixes for cache bypassing\nconst DEFAULT_BYPASS_COOKIES = [\n  'wordpress_logged_in_',\n  'comment_',\n  'woocommerce_',\n  'wordpressuser_',\n  'wordpresspass_',\n  'wordpress_sec_',\n  'yith_wcwl_products',\n  'edd_items_in_cart',\n  'it_exchange_session_',\n  'comment_author',\n  'dshack_level',\n  'auth',\n  'noaffiliate_',\n  'mp_session',\n  'mp_globalcart_'\n]\n\n// Third party query parameter that we need to ignore in a URL\nconst THIRD_PARTY_QUERY_PARAMETERS = [\n  'fbclid',\n  'fb_action_ids',\n  'fb_action_types',\n  'fb_source',\n  '_ga',\n  'age-verified',\n  'ao_noptimize',\n  'usqp',\n  'cn-reloaded',\n  'klaviyo',\n  'gclid',\n  'utm_source',\n  'utm_medium',\n  'utm_campaign',\n  'utm_content',\n  'utm_term',\n  'ref',\n  'utm_term',\n  'hemail'\n]\n\n// Origin Server Response Codes : \n// Includes response status codes for which the execution is stopped and server response of that time is returned\nconst ORIGIN_SERVER_UNUSUAL_RESPONSE_CODES = [\n  // Client Error Response Codes\n  400, 401, 403, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 421, 422, 423, 429, 431, 451,\n  // Server Error Response Codes\n  500, 501, 502, 503, 504, 505, 506, 507, 508, 510, 511,\n  // Redirection Response codes\n  301, 302, 307, 308\n]\n\n/**\n * Function to check if the response status code is within the list \n * of our ORIGIN_SERVER_UNUSUAL_RESPONSE_CODES array and if so, then\n * return TRUE else FALSE\n *\n * @param {Response} response - The origin server response\n * @return {Boolean} has_unusual_response_code - If the response has a status code is \n * within the defined list then return TRUE else FALSE\n */\nfunction has_unusual_origin_server_response_code(response) {\n  if( ORIGIN_SERVER_UNUSUAL_RESPONSE_CODES.includes( response?.status ) ) {\n    response.headers?.set('x-wp-cf-super-cache-worker-origin-response', response.status)\n    return true\n  } else {\n    return false\n  }\n}\n\n/**\n * Function to normalize the URL by removing promotional query parameters from the URL and cache the original URL\n * @param {Object} event - Event Object\n * @return {URL} reqURL - Request URL without promotional query strings\n */\nfunction url_normalize(event) {\n  try {\n    // Fetch the Request URL from the event\n    // Parse the URL for better handling\n    const reqURL = new URL(event?.request?.url)\n\n    // Loop through the promo queries (THIRD_PARTY_QUERY_PARAMETERS) and see if we have any of these queries present in the URL, if so remove them\n    THIRD_PARTY_QUERY_PARAMETERS.forEach( (queryParam) =\u003e {\n\n      // Create the REGEX to text the URL with our desired parameters\n      const promoUrlQuery = new RegExp( '(\u0026?)(' + queryParam + '=\\\\S+)', 'g' )\n\n      // Check if the reqURL.search has these search query parameters\n      if(promoUrlQuery.test( reqURL.search )) {\n\n        // The URL has promo query parameters that we need to remove\n        const urlSearchParams = reqURL.searchParams\n\n        urlSearchParams.delete(queryParam)\n      }\n    } )\n\n    return reqURL\n\n  } catch (err) {\n    return {\n      error: true,\n      errorMessage: <code>URL Handling Error: ${err.message}</code>,\n      errorStatusCode: 400\n    }\n  }\n}\n\n/**\n * Function to check if the current request should be BYPASSed or Cached based on exclusion cookies\n * entered by the user in the plugin settings\n * @param {String} cookieHeader - The cookie header of the current request\n * @param {Array} cookies_list - List of cookies which should not be cached\n * @return {Boolean} blackListedCookieExists - If blacklisted cookie exists in the current request\n */\nfunction are_blacklisted_cookies(cookieHeader, cookies_list) {\n  let blackListedCookieExists = false\n\n  // Make sure both cookieHeader \u0026 cookies_list are defined \u0026 the length of both cookieHeader \u0026 cookies_list \u003e 0\n  if (\n    cookieHeader?.length \u003e 0 \u0026\u0026\n    cookies_list?.length \u003e 0\n  ) {\n    // Split the received request cookie header by semicolon to an Array\n    const cookies = cookieHeader.split(';')\n\n    // Loop through the cookies in the request header and check if there is any cookie present there\n    // which is also mentioned in our bypassed cookies array\n    // if there is then set blackListedCookieExists as true and break out of the loops\n    cookies.every((cookie) =\u003e {\n\n      cookies_list.every((single_black_list_cookie) =\u003e {\n        if (cookie.trim().includes(single_black_list_cookie.trim())) {\n          blackListedCookieExists = true\n          // Found item. Break out from the loop\n          return false\n        }\n\n        // Otherwise continue the loop\n        return true\n      })\n\n      // Check if blackListedCookieExists is true then break out of this loop. Else continue the loop\n      return blackListedCookieExists ? false : true\n    })\n  }\n\n  return blackListedCookieExists // value -\u003e TRUE | FALSE\n}\n\n/**\n * Function to add extra response headers for BYPASSed Requests\n * @param {Response} res - The response object\n * @param {String} reason - The string that hold the bypass reason\n */\nfunction add_bypass_custom_headers(res, reason) {\n  if (res \u0026\u0026 (reason?.length \u003e 0)) {\n    // BYPASS the request and add our custom headers\n    res?.headers?.set('x-wp-cf-super-cache-worker-status', 'bypass')\n    res?.headers?.set('x-wp-cf-super-cache-worker-bypass-reason', reason)\n    res?.headers?.set('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0')\n  }\n}\n\n/**\n * The function that handles the Request\n * @param {Object} event - Received Event object\n * @return {Response} response - Response object that is being returned to the user\n */\nasync function handleRequest(event) {\n\n  const request = event?.request\n  const requestURL = url_normalize(event)\n\n  // Check if we have received any error in the url_normalize() call, if so return that error message\n  if( requestURL?.error ) {\n    return new Response( \n      requestURL.errorMessage,\n      { status: requestURL.errorStatusCode, statusText: requestURL.errorMessage } \n    )\n  }\n\n  let response = false\n  let bypassCache = false\n  const bypassReason = {\n    'req_method': false,\n    'admin_req': false,\n    'file_path_ext': false,\n    'page_excluded': false,\n    'file_excluded': false,\n    'cookie': false\n  }\n  let bypassReasonDetails = ''\n  const cookieHeader = request?.headers?.get('cookie')\n  const reqDetails = {\n    'contentTypeHTML': false\n  }\n\n  // ---------------------------------------------------------\n  // Check - Bypass Request ? - Only Based on Request Headers\n  // ---------------------------------------------------------\n\n  // 1. BYPASS any requests whose request method is not GET or HEAD\n  const allowedReqMethods = ['GET', 'HEAD']\n  if (!bypassCache \u0026\u0026 request) {\n    if (!allowedReqMethods.includes(request.method)) {\n      bypassCache = true\n      bypassReason.req_method = true\n      bypassReasonDetails = <code>Caching not possible for req method ${request.method}</code>\n    }\n  }\n\n  // 2. BYPASS the cache for WP Admin HTML Requests \u0026 Any File That has /wp-admin/ in it \u0026 API endpoints\n  // Get the Accept header of the request being received by the CF Worker\n  const accept = request?.headers?.get('Accept')\n\n  if (!bypassCache \u0026\u0026 accept) {\n\n    // List of path regex that we will BYPASS caching\n    // Path includes - WP Admin Paths, WP REST API, WooCommerce API, EDD API Endpoints\n    const bypass_admin_path = new RegExp(/(\\/(wp-admin)(\\/?))/g)\n    const bypass_cache_paths = new RegExp(/(\\/((wp-admin)|(wc-api)|(edd-api))(\\/?))/g)\n\n    // List of file extensions to be BYPASSed\n    const bypass_file_ext = new RegExp(/\\.(xsl|xml)$/)\n\n    // Check if the request is for WP Admin endpoint \u0026 accept type includes text/html i.e. the main HTML request\n    if ( accept?.includes('text/html') ) {\n      reqDetails.contentTypeHTML = true \n    }\n\n    // Check if the request URL is an admin URL for HTML type requests\n    if ( reqDetails.contentTypeHTML \u0026\u0026 bypass_admin_path.test(requestURL.pathname) ) {\n      bypassCache = true\n      bypassReason.admin_req = true\n      bypassReasonDetails = 'WP Admin HTML request'\n\n    } else if ( bypass_cache_paths.test(requestURL.pathname) || bypass_file_ext.test(requestURL.pathname) ) {\n      // This is for files which starts with /wp-admin/ but not supposed to be cached\n      // E.g. /wp-admin/load-styles.php || /wp-admin/admin-ajax.php\n      // Also API endpoints and xml/xsl files to ensure sitemap isn't cached\n\n      bypassCache = true\n      bypassReason.file_path_ext = true\n      bypassReasonDetails = 'Dynamic File'\n    }\n  }\n\n  // 3. BYPASS the cache if DEFAULT_BYPASS_COOKIES is present in the request\n  // AND also only for the HTML type requests\n  if (\n    !bypassCache \u0026\u0026\n    reqDetails.contentTypeHTML \u0026\u0026\n    cookieHeader?.length \u003e 0 \u0026\u0026\n    DEFAULT_BYPASS_COOKIES.length \u003e 0\n  ) {\n\n    // Separate the request cookies by semicolon and create an Array\n    const cookies = cookieHeader.split(';')\n\n    // Loop through the cookies Array to see if there is any cookies present that is present in DEFAULT_BYPASS_COOKIES\n    let foundDefaultBypassCookie = false\n\n    cookies.every((cookie) =\u003e {\n\n      DEFAULT_BYPASS_COOKIES.every((cookie_prefix) =\u003e {\n\n        if (cookie.trim().startsWith(cookie_prefix.trim())) {\n          bypassCookieName = cookie.trim().split('=')\n          bypassCache = true\n          bypassReason.cookie = true\n          bypassReasonDetails = <code>Default Bypass Cookie [${bypassCookieName[0]}] Present</code>\n          foundDefaultBypassCookie = true\n\n          // Stop the loop\n          return false\n        }\n\n        // Otherwise continue the loop\n        return true\n      })\n\n      // Stop the loop if foundDefaultBypassCookie is TRUE else continue\n      return foundDefaultBypassCookie ? false : true\n    })\n  }\n\n  /**\n   * Check if the Request has been Bypassed so far.\n   * If not, then check if the request exists in CF Edge Cache \u0026 if it does, send it\n   * If it does not exists in CF Edge Cache, then check if the request needs to be Bypassed based on the headers\n   * present in the Response.\n   */\n  if (!bypassCache) { // bypassCache is still FALSE\n\n    // Check if the Request present in the CF Edge Cache\n    const cacheKey = new Request(requestURL, request)\n    const cache = caches?.default // Get global CF cache object for this zone\n\n    // Try to Get this request from this zone's cache\n    try {\n      response = await cache?.match(cacheKey)\n    } catch (err) {\n      return new Response( \n        <code>Error: ${err.message}</code>,\n        { status: 500, statusText: \"Unable to fetch cache from Cloudflare\" } \n      )\n    }\n\n    if (response) { // Cache is present for this request in the CF Edge. Nothing special needs to be done.\n\n      // This request is already cached in the CF Edge. So, simply create a response and set custom headers\n      response = new Response(response?.body, response)\n      response?.headers?.set('x-wp-cf-super-cache-worker-status', 'hit')\n\n    } else { // Cache not present in CF Edge. Check if Req needs to be Bypassed or Cached based on Response header data\n\n      // Fetch the response of this given request normally without any special parameters\n      // so that we can use the response headers set by the plugin at the server level\n      let fetchedResponse\n      try {\n        fetchedResponse = await fetch(request)\n      } catch(err) {\n        return new Response( \n          <code>Error: ${err.message}</code>,\n          { status: 500, statusText: \"Unable to fetch content from the origin server\" } \n        )\n      }\n\n      // If the above if check fails that means we have a good response and lets proceed\n      response = new Response(fetchedResponse.body, fetchedResponse)\n\n      // Check if the response has any unusual origin server response code \u0026 if so then return the response\n      if( has_unusual_origin_server_response_code(response) ) {\n        return response\n      }\n\n      // ---------------------------------------------------------\n      // Check - Bypass Request ? - Based on RESPONSE Headers\n      // ---------------------------------------------------------\n\n      // 4. BYPASS the HTML page requests which are excluded from caching (via WP Admin plugin settings or page level settings)\n      if (\n        !bypassCache \u0026\u0026\n        response?.headers?.get('content-type')?.includes('text/html') \u0026\u0026\n        !response?.headers?.has('x-wp-cf-super-cache-active')\n      ) {\n        bypassCache = true\n        bypassReason.page_excluded = true\n        bypassReasonDetails = 'This page is excluded from caching'\n      }\n\n      // 5. BYPASS the static files (non HTML) which has x-wp-cf-super-cache response header set to no-cache\n      if (!bypassCache \u0026\u0026\n        !response?.headers?.get('content-type')?.includes('text/html') \u0026\u0026\n        (response?.headers?.get('x-wp-cf-super-cache') === 'no-cache')\n      ) {\n        bypassCache = true\n        bypassReason.file_excluded = true\n        bypassReasonDetails = 'This file is excluded from caching'\n      }\n\n      // 6. BYPASS cache if any custom cookie mentioned by the user in the plugin settings is present in the request\n      // Check only for HTML type requests\n      if (\n        !bypassCache \u0026\u0026\n        cookieHeader?.length \u003e 0 \u0026\u0026\n        response?.headers?.get('content-type')?.includes('text/html') \u0026\u0026\n        response?.headers?.has('x-wp-cf-super-cache-cookies-bypass')\n      ) {\n        // Make sure the feature is enabled first\n        if (response?.headers?.get('x-wp-cf-super-cache-cookies-bypass') !== 'swfpc-feature-not-enabled') {\n\n          // Get the list of cookie names entered by the user in the plugin settings\n          let cookies_blacklist = response?.headers?.get('x-wp-cf-super-cache-cookies-bypass')\n\n          if (cookies_blacklist?.length \u003e 0) {\n\n            // Split the received cookie list with | separated and make an Array\n            cookies_blacklist = cookies_blacklist.split('|')\n\n            if (are_blacklisted_cookies(cookieHeader, cookies_blacklist)) {\n              bypassCache = true\n              bypassReason.cookie = true\n              bypassReasonDetails = 'User provided excluded cookies present in request'\n            }\n          }\n        }\n      }\n\n      //-----------------------------------------------------\n      // Check if the request needs to be BYPASSed or Cached\n      //-----------------------------------------------------\n      if (!bypassCache) { // bypassCache is still FALSE. Cache the item in the CF Edge\n\n        // Check if the response status code is not 206 or request method is not HEAD to cache using cache.put(), \n        // as any request with status code === 206 or req.method HEAD cache.put() will not work. \n        // More info: https://developers.cloudflare.com/workers/runtime-apis/cache#put\n        if (response.status !== 206 || request?.method !== 'HEAD') {\n\n          // If the response header has x-wp-cf-super-cache-active overwrite the cache-control header provided by the server value with x-wp-cf-super-cache-active value just to be safe\n          if (response.headers?.has('x-wp-cf-super-cache-active')) {\n            response.headers?.set('Cache-Control', response.headers?.get('x-wp-cf-super-cache-cache-control'))\n          }\n\n          // Set the worker status as miss and put the item in CF cache\n          response.headers?.set('x-wp-cf-super-cache-worker-status', 'miss')\n\n          // Add page in cache using cache.put()\n          try {\n            event.waitUntil( cache.put( cacheKey, response.clone() ) )\n          } catch (err) {\n            return new Response( \n              <code>Cache Put Error: ${err.message}</code>,\n              { status: 500, statusText: <code>Cache Put Error: ${err.message}</code> } \n            )\n          }\n\n        } else {\n\n          // Try to fetch this request again with cacheEverything set to TRUE as that is the only way to cache it\n          // More info: https://developers.cloudflare.com/workers/runtime-apis/request#requestinitcfproperties\n          try {\n            response = await fetch(request, { cf: { cacheEverything: true } })\n          } catch (err) {\n            return new Response( \n              <code>Error: ${err.message}</code>,\n              { status: 500, statusText: \"Unable to fetch content from the origin server with cacheEverything flag\" } \n            )\n          }\n\n          response = new Response(response.body, response)\n\n          // Check if the response has any unusual origin server response code \u0026 if so then return the response\n          if( has_unusual_origin_server_response_code(response) ) {\n            return response\n          }\n\n          // Set the worker status as miss and put the item in CF cache\n          response.headers?.set('x-wp-cf-super-cache-worker-status', 'miss')\n\n        }\n      } else { // bypassCache -\u003e TRUE || Bypass the Request\n\n        // BYPASS the request and add our custom headers\n        add_bypass_custom_headers(response, bypassReasonDetails)\n      }\n\n    }\n\n  } else { // bypassCache -\u003e TRUE\n\n    // Fetch the request from the origin server and send it by adding our custom bypass headers\n    let bypassedResponse\n    try {\n      bypassedResponse = await fetch(request)\n    } catch (err) {\n      return new Response( \n        <code>Error: ${err.message}</code>,\n        { status: 500, statusText: \"Unable to fetch the bypassed content from the origin server\" } \n      )\n    }\n\n    response = new Response(bypassedResponse?.body, bypassedResponse)\n\n    // Check if the response has any unusual origin server response code \u0026 if so then return the response\n    if( has_unusual_origin_server_response_code(response) ) {\n      return response\n    }\n\n    // BYPASS the request and add our custom headers\n    add_bypass_custom_headers(response, bypassReasonDetails)\n  }\n\n  return response\n}\n\n/**\n * Adding event lister to the fetch event to catch the requests and manage them accordingly\n * @param {Object} event \n */\naddEventListener('fetch', event =\u003e {\n  try {\n    return event.respondWith(handleRequest(event))\n  } catch (e) {\n    return event.respondWith( \n      new Response( \n        <code>Error thrown: ${err.message}</code>,\n        { status: 500, statusText: <code>Error thrown: ${err.message}</code> } \n      ) \n    )\n  }\n})",
        "size": 5116
      },
      "success": true,
      "errors": [],
      "messages": []
    }
    
    [2022-04-05 04:57:07] [cloudflare::worker_route_create] Request URL: https://api.cloudflare.com/client/v4/zones/83fce0d845bc43b75874f930809eb136/workers/routes
    [2022-04-05 04:57:08] [cloudflare::worker_route_create] Response: {
      "result": {
        "id": "4a2589ac40814f14882f20f016d0e48f",
        "request_limit_fail_open": false
      },
      "success": true,
      "errors": [],
      "messages": []
    }
    
    [2022-04-05 04:57:08] [cloudflare::purge_cache] Request URL: https://api.cloudflare.com/client/v4/zones/83fce0d845bc43b75874f930809eb136/purge_cache
    [2022-04-05 04:57:08] [cloudflare::purge_cache] Request Body: {"purge_everything":true}
    [2022-04-05 04:57:09] [cloudflare::purge_cache] Response: {
      "result": {
        "id": "83fce0d845bc43b75874f930809eb136"
      },
      "success": true,
      "errors": [],
      "messages": []
    }
    
    [2022-04-05 04:57:09] [fallback_cache::fallback_cache_add_define_cache_wp_config] Constant WP_CACHE does not exists. I will try to add in into wp-config.php
    Thread Starter Nate

    (@goseongguy)

    Just noticed the nginx header is back. The host agent told me they removed it at the source. But it seems they either didn’t do it properly or they faked it by only taking it out of the WordPress part of the .htaccess (it just gets regenerated).

    Plugin Contributor iSaumya

    (@isaumya)

    So, it might be nginx cache, as if you are using worker mode that header would definitely be there.

    Thread Starter Nate

    (@goseongguy)

    Hello Saumya,
    I appreciate your responsiveness.

    I contacted host support again to disable the server cache, and waited 1 day, and the x-nginx-cache header remains gone. (He said the previous agent didn’t disable the cache properly.) So that shouldn’t be in play anymore.

    However, the X-WP-CF-Super-Cache-Worker-Status is still not there. I re-toggled and re-enabled caching a few times and made sure to check all that you mentioned previously.

    Is there anything else we can try or look at?

    • This reply was modified 2 years, 7 months ago by Nate.
    Plugin Contributor iSaumya

    (@isaumya)

    It is really hard for me to guess what can be happening as I do not have access to your CF account and your WP Admin. Without looking at that it is really hard for me to guess.

    Can you send me a screenshot of the worker section inside your CF dashboard? This page: https://i.imgur.com/PMyY0YF.jpeg

    Thread Starter Nate

    (@goseongguy)

    Here is a screenshot of that part: https://imgur.com/pyLvPGp

    Maybe I will try to remove the plugin and re-install it when I get a chance.

    Plugin Contributor iSaumya

    (@isaumya)

    Can you also share a screenshot of the page rule section?

    Thread Starter Nate

    (@goseongguy)

    Here is the page rules section. They are all disabled: https://imgur.com/Q6rgWbT

    Plugin Contributor iSaumya

    (@isaumya)

    This is so damn wired. Can you open the worker inside the CF dashboard as quick edit and send me a screenshot of what you see?

    Thread Starter Nate

    (@goseongguy)

    When I click Edit on the previous screen capture, it just shows a popup with the same info: https://imgur.com/H6MkUP6
    Is that what you mean, or is there a different way to view/edit the script?

    Do I need to click Manage Workers, and “Set up your free custom Cloudflare Workers? subdomain”? That’s something else, right? Or maybe I had to do that all along?

    Plugin Contributor iSaumya

    (@isaumya)

    You need to go to the manage worker section put a subdomain name whatever you like and then you will be able to see the Quick Edit option

    Thread Starter Nate

    (@goseongguy)

    Here is a a screenshot of that: https://imgur.com/tl4huzA

    Looking through the worker code I can see 4 lines where the header gets set to either bypass, hit, or miss. For example:

     // Set the worker status as miss and put the item in CF cache
              response.headers?.set('x-wp-cf-super-cache-worker-status', 'miss')
Viewing 15 replies - 1 through 15 (of 23 total)
  • The topic ‘Missing X-WP-CF-Super-Cache-Worker-Status response header’ is closed to new replies.