Slide 17
Slide 17 text
17
Remix
の採用
加えて Request
から Response
を返すだけのシンプルな仕組みなのが嬉しい
1.
実際には json
や defer
などのレスポンスを生成する utility function
を利用する ↩︎
Cache-Control
ヘッダを自由に設定できる
` `
export async function loader({ params, request }: LoaderFunctionArgs) {
const restaurant = await fetchRestaurant(params.restaurantId)
return new Response(
JSON.stringify({restaurant}),
{headers: {
'Content-Type': 'application/json',
'Cache-Control': 'max-age=300,stale-while-revalidate=86400',
'Surrogate-Key': 'purge-key-for-fastly',
}}
)
}
[1]