Skip to content

Instantly share code, notes, and snippets.

@dz0ny
Created July 18, 2023 20:35
Show Gist options
  • Save dz0ny/6a8684dc373d4619f271a6c0731cf112 to your computer and use it in GitHub Desktop.
Save dz0ny/6a8684dc373d4619f271a6c0731cf112 to your computer and use it in GitHub Desktop.
Caching proxy za vreme.si
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