Stop caching db requests on static home page
This commit is contained in:
parent
4039d3999d
commit
1f0f9aa906
@ -1,4 +1,3 @@
|
|||||||
import { getPhotosCachedCached, getPhotosCountCached } from '@/photo/cache';
|
|
||||||
import {
|
import {
|
||||||
INFINITE_SCROLL_INITIAL_HOME,
|
INFINITE_SCROLL_INITIAL_HOME,
|
||||||
INFINITE_SCROLL_MULTIPLE_HOME,
|
INFINITE_SCROLL_MULTIPLE_HOME,
|
||||||
@ -9,12 +8,16 @@ import { Metadata } from 'next/types';
|
|||||||
import { MAX_PHOTOS_TO_SHOW_OG } from '@/image-response';
|
import { MAX_PHOTOS_TO_SHOW_OG } from '@/image-response';
|
||||||
import InfinitePhotoScroll from '../photo/InfinitePhotoScroll';
|
import InfinitePhotoScroll from '../photo/InfinitePhotoScroll';
|
||||||
import PhotosLarge from '@/photo/PhotosLarge';
|
import PhotosLarge from '@/photo/PhotosLarge';
|
||||||
|
import { cache } from 'react';
|
||||||
|
import { getPhotos, getPhotosCount } from '@/services/vercel-postgres';
|
||||||
|
|
||||||
export const dynamic = 'force-static';
|
export const dynamic = 'force-static';
|
||||||
|
|
||||||
|
const getPhotosCached = cache(getPhotos);
|
||||||
|
|
||||||
export async function generateMetadata(): Promise<Metadata> {
|
export async function generateMetadata(): Promise<Metadata> {
|
||||||
// Make homepage queries resilient to error on first time setup
|
// Make homepage queries resilient to error on first time setup
|
||||||
const photos = await getPhotosCachedCached({
|
const photos = await getPhotosCached({
|
||||||
limit: MAX_PHOTOS_TO_SHOW_OG,
|
limit: MAX_PHOTOS_TO_SHOW_OG,
|
||||||
})
|
})
|
||||||
.catch(() => []);
|
.catch(() => []);
|
||||||
@ -27,11 +30,11 @@ export default async function HomePage() {
|
|||||||
photos,
|
photos,
|
||||||
photosCount,
|
photosCount,
|
||||||
] = await Promise.all([
|
] = await Promise.all([
|
||||||
getPhotosCachedCached({
|
getPhotosCached({
|
||||||
limit: INFINITE_SCROLL_INITIAL_HOME,
|
limit: INFINITE_SCROLL_INITIAL_HOME,
|
||||||
})
|
})
|
||||||
.catch(() => []),
|
.catch(() => []),
|
||||||
getPhotosCountCached()
|
getPhotosCount()
|
||||||
.catch(() => 0),
|
.catch(() => 0),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import { makeUrlAbsolute, shortenUrl } from '@/utility/url';
|
|||||||
// HARD-CODED GLOBAL CONFIGURATION
|
// HARD-CODED GLOBAL CONFIGURATION
|
||||||
|
|
||||||
export const SHOULD_PREFETCH_ALL_LINKS: boolean | undefined = undefined;
|
export const SHOULD_PREFETCH_ALL_LINKS: boolean | undefined = undefined;
|
||||||
export const SHOULD_DEBUG_SQL = false;
|
export const SHOULD_DEBUG_SQL = true;
|
||||||
|
|
||||||
// META / DOMAINS
|
// META / DOMAINS
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user