Cloudflare Workers and Cache issues for UTM params

can anybody help us to setup a worker for us which actually hits cache when we visit the page through utm params? we have one home page which is already being cache and we also have setup apo plugin on wordpress website. We have high number of users which are coming from ads and as they have moer utm params its bypassing our cache always which really degrade our web vital scores. Can anybody please suggest any way to fix this thing? We have setup worker as well which is also fetching from cache though not sure it has lot of high miss cache ratio nearly like around 30% times still We also have enabled reserved cache so that it reduces our call to origin still no luck! We have created three rules Cache Everything -> which has edge ttl set to 1 day by ignoring all cache headers Bypass wp-admin -> for specific wp admin routes to bypass cache Cache homepage for one month -> Edge ttl set to 1 month for homepage Worker script addEventListener('fetch', event => { event.respondWith(handleRequest(event.request, event)); }); async function handleRequest(request, event) { const url = new URL(request.url); if (url.pathname === "/" url.pathname === "/index.html" url.pathname === 'index.php') { url.search = ""; const newRequest = new Request(url.toString(), request); const cache = caches.default; let response = await cache.match(newRequest); if (!response) { response = await fetch(newRequest); event.waitUntil(cache.put(newRequest, response.clone())); } return response; } return fetch(request); } Any help really appriciated as we are facing it from months and now its really impacting us really so much!!!!
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?