aws cloudfront 로 제공하는 음성, 동영상 리소스가 있는데, 최근 인코딩을 잘못하여 모바일에서 버퍼링을 불러 일으키는 동영상이 있었는데, 인코딩을 최적화하여 다시 s3 로 업로드 하였으나 cdn 에서 문제가 있는 파일을 캐싱하고 있어서 여전히 버퍼링이 생겼고, 이를 해결하기 위해 aws 콘솔에서 별도의 invalidate 로 해결을 했었는데, 직접 invalidate 하지 않고 하는 방법을 찾아보고 아래와 같이 해결을 했다.
아래의 매뉴얼을 보고 그대로 하면 되는데, aws 콘솔 화면에서 cloudfront query string whitelist 를 어디서 설정할 수 있는지 좀 헤매서 정리함.
Values That You Specify When You Create or Update a Distribution - Amazon CloudFront
Values That You Specify When You Create or Update a Distribution When you create a new distribution or update an existing distribution, you specify the following values. For information about creating or updating a distribution by using the CloudFront cons
docs.aws.amazon.com
Values That You Specify When You Create or Update a Distribution - Amazon CloudFront
Values That You Specify When You Create or Update a Distribution When you create a new distribution or update an existing distribution, you specify the following values. For information about creating or updating a distribution by using the CloudFront cons
docs.aws.amazon.com
1. query string 을 기반으로 캐싱을 하지 않도록 하려는 cloudfront distribution 설정 화면 -> Behaviors 클릭
2. default 로 설정된 behavior 가 하나 존재하는데 그걸 Edit 버튼을 눌러 수정
3. Query String Forwarding and Caching 설정을 Forward all, cache based on whitelist 로 변경 후 Query String whitelist 에 원하는 query string key 를 지정
4. 저장 후, 테스트 해보면 ?ver=1 로 했을 때 Hit 이 되는 상황이라 할 때, ?ver=2 로 요청을 아무도 한적이 없다면 Miss 가 되면서 엣지 로케이션에 새로 업로드한 동일한 파일명의 파일이 캐싱될 것이다.