Created
October 3, 2018 08:31
-
-
Save vdbelt/d305645d5a48c4d8c1413f61d968885b to your computer and use it in GitHub Desktop.
Ignore query string for optimal caching
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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