-
2024.10.15 Cache controlTIL 2024. 10. 16. 00:36
인터넷이 안되는 환경에서도 이미지를 보고 싶다는 요구 사항이 있었다.
처음에는 인터넷이 되는 곳에서 데이터를 받고 나서 인터넷이 안 되는 환경으로 전환되는 구조였다.
음 브라우저 캐시가 생각나 이를 적용해보았다.
S3에서 이미지를 받아오는데 요청 쿼리 스트링에 cache control 관련 설정인 max-age나 value를 보내면 응답에 max-age가 붙어서 오는 구조이다.
S3 자체의 메타데이터를 수정하면 다른 서비스에 영향을 줄까 걱정했지만, 좋은 파라미터가 있었다.
https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#getObject-property
추가로 알아본 것이 브라우저 캐시는 메모리 또는 디스크에서 가져오는데, 최대 크기와 디스크에 저장되는 기준에 대한 자료가 부족하다.
디스크의 10%까지 사용할 수 있다는 얘기도 있고, 디스크 캐시의 조건은 아마 용량인 것 같다. 자주 리로드해도 디스크에 저장된 캐시는 메모리로 올라오지 않고 계속 fromDisk 상태로 나타난다.
캐시 용량도 아마 차오르면 삭제가 이뤄지는거 같아 찾아보니 LFU 알고리즘등이 있다. 빈도 수를 계산하는 알고리즘인 것 같다.
'TIL' 카테고리의 다른 글
2024.10.19 SSL (0) 2024.10.19 2024.10.17 환기 (0) 2024.10.17 2024.10.08 Duplicate Requests, Throttling Design Pattern (0) 2024.10.09 2024.10.05 NAT (0) 2024.10.05 2024.09.21 java-acquire-lock-by-key (0) 2024.09.22