@@ -2,6 +2,7 @@ import { type NextPageContext } from 'next';
22
33import HomeScene from '~/scenes/HomeScene' ;
44import { type HomePageProps } from '~/types/pages' ;
5+ import { NEXT_1H_CACHE_HEADER } from '~/util/Constants' ;
56import getApiUrl from '~/util/getApiUrl' ;
67import urlWithQuery from '~/util/urlWithQuery' ;
78
@@ -12,7 +13,6 @@ function Index(props: HomePageProps) {
1213const LIMIT = 8 ;
1314
1415Index . getInitialProps = async ( ctx : NextPageContext ) => {
15- console . warn ( ctx . query ) ;
1616 if ( ctx . res && ctx . query && Object . keys ( ctx . query ) . length > 0 ) {
1717 ctx . res . writeHead ( 302 , {
1818 Location : urlWithQuery ( '/packages' , ctx . query ) ,
@@ -29,13 +29,16 @@ Index.getInitialProps = async (ctx: NextPageContext) => {
2929 hasNativeCode : 'true' ,
3030 } ) ,
3131 ctx
32- )
32+ ) ,
33+ NEXT_1H_CACHE_HEADER
3334 ) ;
3435 const recentlyAddedResponse = await fetch (
35- getApiUrl ( urlWithQuery ( '/libraries' , { order : 'added' , limit : LIMIT . toString ( ) } ) , ctx )
36+ getApiUrl ( urlWithQuery ( '/libraries' , { order : 'added' , limit : LIMIT . toString ( ) } ) , ctx ) ,
37+ NEXT_1H_CACHE_HEADER
3638 ) ;
3739 const recentlyUpdatedResponse = await fetch (
38- getApiUrl ( urlWithQuery ( '/libraries' , { order : 'updated' , limit : LIMIT . toString ( ) } ) , ctx )
40+ getApiUrl ( urlWithQuery ( '/libraries' , { order : 'updated' , limit : LIMIT . toString ( ) } ) , ctx ) ,
41+ NEXT_1H_CACHE_HEADER
3942 ) ;
4043 const popularResponse = await fetch (
4144 getApiUrl (
@@ -47,10 +50,14 @@ Index.getInitialProps = async (ctx: NextPageContext) => {
4750 wasRecentlyUpdated : 'true' ,
4851 } ) ,
4952 ctx
50- )
53+ ) ,
54+ NEXT_1H_CACHE_HEADER
5155 ) ;
5256
53- const statisticResponse = await fetch ( getApiUrl ( urlWithQuery ( '/libraries/statistic' , { } ) , ctx ) ) ;
57+ const statisticResponse = await fetch (
58+ getApiUrl ( urlWithQuery ( '/libraries/statistic' , { } ) , ctx ) ,
59+ NEXT_1H_CACHE_HEADER
60+ ) ;
5461
5562 return {
5663 mostDownloaded : await mostDownloadedResponse . json ( ) ,
0 commit comments