Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ignore query string for optimal caching
addEventListener('fetch', event => {
event.respondWith(ignoreQueryString(event.request))
})
async function ignoreQueryString(request) {
let url = new URL(request.url)
url.search = ''
let modifiedRequest = new Request(url, request)
return fetch(modifiedRequest)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment