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