Complete the code to set a cache-control header for 1 hour in a Remix loader.
export const loader = async () => {
return new Response(null, {
headers: { 'Cache-Control': '[1]' }
});
};The max-age=3600 directive tells the browser to cache the response for 3600 seconds (1 hour).
Complete the code to add a cache-control header that allows public caching for 5 minutes.
export const loader = async () => {
return new Response(null, {
headers: { 'Cache-Control': '[1]' }
});
};The public, max-age=300 header allows caching by any cache for 300 seconds (5 minutes).
Fix the error in the cache-control header to enable caching for 10 minutes.
export const loader = async () => {
return new Response(null, {
headers: { 'Cache-Control': '[1]' }
});
};Only max-age=600 correctly enables caching for 600 seconds (10 minutes). Adding 'no-store' or 'no-cache' disables caching.
Fill both blanks to set a cache-control header that caches publicly for 1 day and allows stale content for 1 hour.
export const loader = async () => {
return new Response(null, {
headers: { 'Cache-Control': '[1], [2]' }
});
};max-age=86400 caches for 1 day (86400 seconds). stale-while-revalidate=3600 allows serving stale content for 1 hour while revalidating.
Fill all three blanks to create a cache-control header that caches publicly for 30 minutes, allows stale content for 5 minutes, and forces revalidation after 1 hour.
export const loader = async () => {
return new Response(null, {
headers: { 'Cache-Control': '[1], [2], [3]' }
});
};public allows shared caching. max-age=1800 caches for 30 minutes. must-revalidate forces the cache to revalidate after expiration. stale-while-revalidate=300 is not used here because revalidation is forced.
