Hello
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
1. Cache Everything -> which has edge ttl set to 1 day by ignoring all cache headers
2. Bypass wp-admin -> for specific wp admin routes to bypass cache
3. 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!!!!
1 Reply
we have selected cache level to standard
we basically want to ignore all query strings when its homepage
though we tried to apply ignore query string option
however it only applies on certain utm keywords and not for our custom ones like we have some as adgroup then in such cases it again bypass it
we are on pro plan
we tried this i guess
but i think apo overrides this?
okay
we cannot actually disalbe apo because otherwise we have less ttfb
i mean high ttfb issues
because its responsible for creating static pages of our site right now