

Doc AWS SDK 예제 GitHub 리포지토리에서 더 많은 SDK 예제를 사용할 수 있습니다. [AWS](https://github.com/awsdocs/aws-doc-sdk-examples) 

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# CloudFront Functions 뷰어 응답 이벤트에 캐시 제어 헤더 추가
<a name="cloudfront_example_cloudfront_functions_add_cache_control_header_section"></a>

다음 코드 예제에서는 CloudFront Functions 뷰어 응답 이벤트에 캐시 제어 헤더를 추가하는 방법을 보여줍니다.

------
#### [ JavaScript ]

**CloudFront Functions를 위한 JavaScript 런타임 2.0**  
 GitHub에 더 많은 내용이 있습니다. [CloudFront Functions 예제](https://github.com/aws-samples/amazon-cloudfront-functions/tree/main/add-cache-control-header) 리포지토리에서 전체 예시를 찾고 설정 및 실행하는 방법을 배워보세요.

```
async function handler(event) {
    var response = event.response;
    var headers = response.headers;
    
    if (response.statusCode >= 200 && response.statusCode < 400) {
        // Set the cache-control header
        headers['cache-control'] = {value: 'public, max-age=63072000'};
    }
        
    // Return response to viewers
    return response;
}
```

------