Skip to content

Instantly share code, notes, and snippets.

@vdbelt
Created October 3, 2018 08:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vdbelt/d305645d5a48c4d8c1413f61d968885b to your computer and use it in GitHub Desktop.
Save vdbelt/d305645d5a48c4d8c1413f61d968885b to your computer and use it in GitHub Desktop.
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