Prevent generateMetadata()
from destroying TTFB metric
#50809
-
We use Any suggestion on how to cache the result of Example of our use case: export const staticHttpGet = async <D extends HTTPGetInterface>(
url: D['url'],
params: D['params'],
next: NextFetchRequestConfig | undefined = undefined
): Promise<D['result']> => {
let path = `https://some_url.com${url}`
if (params !== undefined) {
path += '?' + toHTTPQueryString(params)
}
return fetch(path, {
method: 'GET',
headers: {
Accept: 'application/json',
},
next,
})
.then(resp => resp.json())
.then(handleJson)
}
const queryFilters = async (params: GetAvailableFilters['params']) => {
return await staticHttpGet<GetAvailableFilters>(
'/api/available-product-filters',
params,
{
revalidate: 600,
}
)
}
const queryProducts = async (
productParams: SearchProductFrontEnd['params']
) => {
return await staticHttpGet<SearchProductFrontEnd>(
'/api/products',
productParams,
{
revalidate: 600,
}
)
}
export const generateMetadata = async ({
params,
}: {
params: Params
}): Promise<Metadata> => {
const [filters, products] = await Promise.all([
queryFilters(getAvailableFilterParams(params)),
queryProducts({
...getDefaultParams(params),
takeCount: 1,
page: 1,
}),
])
return {
title:'....'
//some stuff based on 'filters' and 'products' variable
}
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
It seems that 'appDir' still has significant issues as of summer 2023. I hope it will be ready for production by the end of autumn. |
Beta Was this translation helpful? Give feedback.
-
Any update on this? Running into this on one of the more recent builds. |
Beta Was this translation helpful? Give feedback.
It seems that 'appDir' still has significant issues as of summer 2023. I hope it will be ready for production by the end of autumn.