8000 cache weather requests · manjaro-sway/manjaro-sway@c436ca7 · GitHub
[go: up one dir, main page]

Skip to content

Commit

Permalink
cache weather requests
Browse files Browse the repository at this point in the history
  • Loading branch information
boredland authored Sep 6, 2024
1 parent 8ed492c commit c436ca7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions docs/functions/weather/[location].ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@ export const onRequest: PagesFunction<Env> = async (context) => {

const weatherRequest = await fetch(
`https://api.open-meteo.com/v1/forecast?${searchParams.toString()}`,
{
cf: {
// Cache the response for
15 minutes to not overwhelm the open-meteo rate limits
cacheTtl: 60 * 15,
},
},
);

const result = await weatherRequest.json<{
Expand Down

0 comments on commit c436ca7

Please sign in to comment.
0