Skip to content

Commit

Permalink
increase Cache-Control for livingdex to 45s
Browse files Browse the repository at this point in the history
  • Loading branch information
itsjavi committed Jul 25, 2024
1 parent 36bcc1a commit 2c75403
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/config/cache.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const cacheConfig = {
apiResponseCacheSeconds: 30,
apiResponseCacheSeconds: 45,
}
8 changes: 7 additions & 1 deletion src/pages/apps/livingdex/[dexid].tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { GetServerSidePropsContext } from 'next'

import { cacheConfig } from '@/config/cache'
import { getLegacyLivingDexRepository } from '@/features/livingdex/repository'
import { getPresets } from '@/features/livingdex/repository/presets'
import { PresetDexMap } from '@/features/livingdex/repository/presets/types'
Expand Down Expand Up @@ -47,7 +48,12 @@ const Page = ({ dexData, presets }: { dexData: any; presets: PresetDexMap }) =>
// with a fresh value. If you refresh the page, you will see the new value.
// https://nextjs.org/docs/basic-features/data-fetching/overview#getserversideprops-server-side-rendering
export async function getServerSideProps(context: GetServerSidePropsContext) {
context.res.setHeader('Cache-Control', 'public, s-maxage=20, stale-while-revalidate=59')
// context.res.setHeader('Cache-Control', 'public, s-maxage=20, stale-while-revalidate=59')
const swrSecs = cacheConfig.apiResponseCacheSeconds * 2
context.res.setHeader(
'Cache-Control',
'public, s-maxage=' + cacheConfig.apiResponseCacheSeconds + ', stale-while-revalidate=' + swrSecs,
)
const dexid = context.params?.dexid

const dexRepo = getLegacyLivingDexRepository()
Expand Down

1 comment on commit 2c75403

@vercel
Copy link

@vercel vercel bot commented on 2c75403 Jul 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.