Apply request caching to core routes
This commit is contained in:
parent
0f43b1977b
commit
cbc5dfd30b
@ -15,8 +15,7 @@ import { ReactNode, cache } from 'react';
|
||||
import { FilmSimulation } from '@/simulation';
|
||||
import { getPhotosFilmSimulationDataCached } from '@/simulation/data';
|
||||
|
||||
const getPhotoCachedCached =
|
||||
cache((photoId: string) => getPhotoCached(photoId));
|
||||
const getPhotoCachedCached = cache(getPhotoCached);
|
||||
|
||||
interface PhotoFilmSimulationProps {
|
||||
params: { photoId: string, simulation: FilmSimulation }
|
||||
|
||||
@ -3,6 +3,10 @@ import { FilmSimulation, generateMetaForFilmSimulation } from '@/simulation';
|
||||
import FilmSimulationOverview from '@/simulation/FilmSimulationOverview';
|
||||
import { getPhotosFilmSimulationDataCached } from '@/simulation/data';
|
||||
import { Metadata } from 'next/types';
|
||||
import { cache } from 'react';
|
||||
|
||||
const getPhotosFilmSimulationDataCachedCached =
|
||||
cache(getPhotosFilmSimulationDataCached);
|
||||
|
||||
interface FilmSimulationProps {
|
||||
params: { simulation: FilmSimulation }
|
||||
@ -14,7 +18,7 @@ export async function generateMetadata({
|
||||
const [
|
||||
photos,
|
||||
{ count, dateRange },
|
||||
] = await getPhotosFilmSimulationDataCached({
|
||||
] = await getPhotosFilmSimulationDataCachedCached({
|
||||
simulation,
|
||||
limit: GRID_THUMBNAILS_TO_SHOW_MAX,
|
||||
});
|
||||
@ -49,7 +53,7 @@ export default async function FilmSimulationPage({
|
||||
const [
|
||||
photos,
|
||||
{ count, dateRange },
|
||||
] = await getPhotosFilmSimulationDataCached({
|
||||
] = await getPhotosFilmSimulationDataCachedCached({
|
||||
simulation,
|
||||
limit: GRID_THUMBNAILS_TO_SHOW_MAX,
|
||||
});
|
||||
|
||||
@ -4,6 +4,10 @@ import FilmSimulationOverview from '@/simulation/FilmSimulationOverview';
|
||||
import FilmSimulationShareModal from '@/simulation/FilmSimulationShareModal';
|
||||
import { getPhotosFilmSimulationDataCached } from '@/simulation/data';
|
||||
import { Metadata } from 'next/types';
|
||||
import { cache } from 'react';
|
||||
|
||||
const getPhotosFilmSimulationDataCachedCached =
|
||||
cache(getPhotosFilmSimulationDataCached);
|
||||
|
||||
interface FilmSimulationProps {
|
||||
params: { simulation: FilmSimulation }
|
||||
@ -15,7 +19,7 @@ export async function generateMetadata({
|
||||
const [
|
||||
photos,
|
||||
{ count, dateRange },
|
||||
] = await getPhotosFilmSimulationDataCached({
|
||||
] = await getPhotosFilmSimulationDataCachedCached({
|
||||
simulation,
|
||||
limit: GRID_THUMBNAILS_TO_SHOW_MAX,
|
||||
});
|
||||
@ -50,7 +54,7 @@ export default async function Share({
|
||||
const [
|
||||
photos,
|
||||
{ count, dateRange },
|
||||
] = await getPhotosFilmSimulationDataCached({
|
||||
] = await getPhotosFilmSimulationDataCachedCached({
|
||||
simulation,
|
||||
limit: GRID_THUMBNAILS_TO_SHOW_MAX,
|
||||
});
|
||||
|
||||
@ -15,8 +15,7 @@ import { PhotoCameraProps, cameraFromPhoto } from '@/camera';
|
||||
import { getPhotosCameraDataCached } from '@/camera/data';
|
||||
import { ReactNode, cache } from 'react';
|
||||
|
||||
const getPhotoCachedCached =
|
||||
cache((photoId: string) => getPhotoCached(photoId));
|
||||
const getPhotoCachedCached = cache(getPhotoCached);
|
||||
|
||||
export async function generateMetadata({
|
||||
params: { photoId, make, model },
|
||||
|
||||
@ -7,6 +7,9 @@ import {
|
||||
} from '@/photo';
|
||||
import { getPhotosCameraDataCached } from '@/camera/data';
|
||||
import CameraOverview from '@/camera/CameraOverview';
|
||||
import { cache } from 'react';
|
||||
|
||||
const getPhotosCameraDataCachedCached = cache(getPhotosCameraDataCached);
|
||||
|
||||
export async function generateMetadata({
|
||||
params,
|
||||
@ -16,7 +19,7 @@ export async function generateMetadata({
|
||||
const [
|
||||
photos,
|
||||
{ count, dateRange },
|
||||
] = await getPhotosCameraDataCached({
|
||||
] = await getPhotosCameraDataCachedCached({
|
||||
camera,
|
||||
limit: GRID_THUMBNAILS_TO_SHOW_MAX,
|
||||
});
|
||||
@ -51,7 +54,7 @@ export default async function CameraPage({ params }: CameraProps) {
|
||||
const [
|
||||
photos,
|
||||
{ count, dateRange },
|
||||
] = await getPhotosCameraDataCached({
|
||||
] = await getPhotosCameraDataCachedCached({
|
||||
camera,
|
||||
limit: INFINITE_SCROLL_INITIAL_GRID,
|
||||
});
|
||||
|
||||
@ -12,6 +12,9 @@ import {
|
||||
} from '@/photo';
|
||||
import { getPhotosCameraDataCached } from '@/camera/data';
|
||||
import CameraOverview from '@/camera/CameraOverview';
|
||||
import { cache } from 'react';
|
||||
|
||||
const getPhotosCameraDataCachedCached = cache(getPhotosCameraDataCached);
|
||||
|
||||
export async function generateMetadata({
|
||||
params,
|
||||
@ -21,7 +24,7 @@ export async function generateMetadata({
|
||||
const [
|
||||
photos,
|
||||
{ count, dateRange },
|
||||
] = await getPhotosCameraDataCached({
|
||||
] = await getPhotosCameraDataCachedCached({
|
||||
camera,
|
||||
limit: GRID_THUMBNAILS_TO_SHOW_MAX,
|
||||
});
|
||||
@ -56,7 +59,7 @@ export default async function Share({ params }: CameraProps) {
|
||||
const [
|
||||
photos,
|
||||
{ count, dateRange },
|
||||
] = await getPhotosCameraDataCached({
|
||||
] = await getPhotosCameraDataCachedCached({
|
||||
camera: cameraFromParams,
|
||||
limit: INFINITE_SCROLL_INITIAL_GRID,
|
||||
});
|
||||
|
||||
@ -5,6 +5,9 @@ import TagOverview from '@/tag/TagOverview';
|
||||
import { getPhotosTagDataCached } from '@/tag/data';
|
||||
import type { Metadata } from 'next';
|
||||
import { redirect } from 'next/navigation';
|
||||
import { cache } from 'react';
|
||||
|
||||
const getPhotosTagDataCachedCached = cache(getPhotosTagDataCached);
|
||||
|
||||
interface TagProps {
|
||||
params: { tag: string }
|
||||
@ -18,7 +21,7 @@ export async function generateMetadata({
|
||||
const [
|
||||
photos,
|
||||
{ count, dateRange },
|
||||
] = await getPhotosTagDataCached({
|
||||
] = await getPhotosTagDataCachedCached({
|
||||
tag,
|
||||
limit: GRID_THUMBNAILS_TO_SHOW_MAX,
|
||||
});
|
||||
@ -57,7 +60,7 @@ export default async function TagPage({
|
||||
const [
|
||||
photos,
|
||||
{ count, dateRange },
|
||||
] = await getPhotosTagDataCached({
|
||||
] = await getPhotosTagDataCachedCached({
|
||||
tag,
|
||||
limit: GRID_THUMBNAILS_TO_SHOW_MAX,
|
||||
});
|
||||
|
||||
@ -4,6 +4,9 @@ import TagOverview from '@/tag/TagOverview';
|
||||
import TagShareModal from '@/tag/TagShareModal';
|
||||
import { getPhotosTagDataCached } from '@/tag/data';
|
||||
import type { Metadata } from 'next';
|
||||
import { cache } from 'react';
|
||||
|
||||
const getPhotosTagDataCachedCached = cache(getPhotosTagDataCached);
|
||||
|
||||
interface TagProps {
|
||||
params: { tag: string }
|
||||
@ -17,7 +20,7 @@ export async function generateMetadata({
|
||||
const [
|
||||
photos,
|
||||
{ count, dateRange },
|
||||
] = await getPhotosTagDataCached({
|
||||
] = await getPhotosTagDataCachedCached({
|
||||
tag,
|
||||
limit: GRID_THUMBNAILS_TO_SHOW_MAX,
|
||||
});
|
||||
@ -54,7 +57,7 @@ export default async function Share({
|
||||
const [
|
||||
photos,
|
||||
{ count, dateRange },
|
||||
] = await getPhotosTagDataCached({
|
||||
] = await getPhotosTagDataCachedCached({
|
||||
tag,
|
||||
limit: GRID_THUMBNAILS_TO_SHOW_MAX,
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user