응답에 Cache-Control 헤더 추가 - Amazon CloudFront

응답에 Cache-Control 헤더 추가

다음 뷰어 응답 함수는 응답에 Cache-Control HTTP 헤더를 추가합니다. 헤더는 웹 브라우저에 최대 2년(63,072,000초) 동안 응답을 캐시하도록 명령하는 max-age 명령을 사용합니다. 자세한 내용은 MDN 웹 문서 웹 사이트의 Cache-Control을 참조하세요.

GitHub에서 이 예제를 참조하세요.

JavaScript runtime 2.0
async function handler(event) { const response = event.response; const headers = response.headers; // Set the cache-control header headers['cache-control'] = {value: 'public, max-age=63072000'}; // Return response to viewers return response; }
JavaScript runtime 1.0
function handler(event) { var response = event.response; var headers = response.headers; // Set the cache-control header headers['cache-control'] = {value: 'public, max-age=63072000'}; // Return response to viewers return response; }