Skip to content

Commit

Permalink
feat: add cache-control header
Browse files Browse the repository at this point in the history
  • Loading branch information
sooluh committed Mar 2, 2024
1 parent 0f51411 commit b2139b2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/controllers/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export const search = (app: FastifyInstance) => {
const result = await scrape({ query: q, province, regency, district }, provider.value)
const response = createSpecResponse(result)

reply.header('Cache-Control', 's-maxage=86400, stale-while-revalidate=604800')

return reply.send(response)
}
}
2 changes: 1 addition & 1 deletion src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { FastifyInstance, FastifyPluginOptions } from 'fastify'
const load = async (app: FastifyInstance, _: FastifyPluginOptions) => {
const providers = new SequentialRoundRobin<ProviderList>([
{ hostname: 'direktorikodepos.org', segment: 'wilayah' },
{ hostname: 'carikodepos.com', segment: 'daerah' },
// { hostname: 'carikodepos.com', segment: 'daerah' },
])

app.decorate('providers', providers)
Expand Down

0 comments on commit b2139b2

Please sign in to comment.