I believe I've isolated my TTFB delay to a service worker. It's the first thing that happens when I try to pull up any page, and takes over 2 second before anything else can happen, but only when Cloudflare is active. When Cloudfare is not active (pauses) the same script takes 138ms. If I'm understanding correctly, here is the script in question. Seems to hang at respondWith....but I'm not at all sure what I'm looking at... Any ideas why it would hang up for over 2 seconds only with CF is active?
Code:
const CACHE_NAME = 'offrol240424';const OFFLINE_URL = 'offline.html';self.addEventListener('install', (event) => { event.waitUntil( caches.open(CACHE_NAME) .then((cache) => cache.add(OFFLINE_URL)) );});self.addEventListener('fetch', (event) => { event.respondWith( caches.match(event.request) .then((response) => { // Cache hit - return response if (response) { return response; } // Otherwise, fetch the requested resource from the network return fetch(event.request) .catch(() => caches.match(OFFLINE_URL)); }) );});
Statistics: Posted by CPTOM — Sat Jul 12, 2025 11:01 pm