Worker - Remove Cache for Specified URL's

I have the following code for a Worker to remove the Ehid from the URL

But I need to remove it for specified URL’s within this script. I’m not sure how to do that and was wondering if anyone could maybe with this? I don’t want it to cache different parts of my sites/paths e.g images etc


addEventListener(‘fetch’, event => {


  • Fetch and log a given request object

  • @param {Request} request
    async function fetchAndLog(request) {
    if (request.url.includes(‘ehid’)) {
    let url = new URL(request.url)

    //delete the ehid query param for the url
    //in the same way you can remove other parameters

    //preserve the method and headers from the original request
    let init = {
    method: request.method,
    headers: request.headers
    //fetch the cached endpoint (without the ehid)
    const response = await fetch(url, init)
    return response