Created
July 18, 2023 20:35
-
-
Save dz0ny/6a8684dc373d4619f271a6c0731cf112 to your computer and use it in GitHub Desktop.
Caching proxy za vreme.si
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
export default { | |
async fetch(request) { | |
let url = new URL(request.url); | |
url.hostname = "www.vreme.si"; | |
let newRequest = new Request(url, request); | |
let response = await fetch(newRequest, { | |
cf: { | |
cacheTtl: 60, | |
cacheEverything: true, | |
}, | |
}); | |
response = new Response(response.body, response); | |
// Trik ki spravi vse assete, html in REST API v public cache | |
// na cloudflare to pomeni da ga bo serviral iz globalnega cache vsem obiskovalcem. | |
response.headers.set("Cache-Control", "public,max-age=60"); | |
return response; | |
}, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment