Skip to content

Commit

Permalink
Modify cache lifetime
Browse files Browse the repository at this point in the history
  • Loading branch information
jcuenod committed Aug 3, 2024
1 parent 23df52b commit 3e97949
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import { convertDeserializedQueryObject } from "https://cdn.skypack.dev/friendly
import { getModuleIdsFromModules } from "./helpers/moduleInfo.ts"
import { generateParallelIdQueryFromCorpora } from "./helpers/parallelIdQueryBuilder.ts"

// 604800 = 168 hours
// 21600 = 6 hours
const CACHE_FOR_N_SECONDS = 21600

type ErrorResponse = {
error: boolean,
code: string,
Expand Down Expand Up @@ -323,7 +327,7 @@ router.get("/api/v2/highlight", async (ctx) => {
corpusFilter,
})
ctx.response.body = matchingSyntaxNodes
ctx.response.headers.set("Cache-Control", "max-age=604800")
ctx.response.headers.set("Cache-Control", `max-age=${CACHE_FOR_N_SECONDS}`)
}
catch (error) {
console.log(error)
Expand All @@ -346,4 +350,4 @@ app.addEventListener("listen", () => {
})
app.listen({
port: +(Deno.env.get("PORT") || 3000)
})
})

0 comments on commit 3e97949

Please sign in to comment.