nginx 20

gunzip을 사용해 Cache key절약

아래설정으로 Accept-Encoding이 없을 경우 gzip으로 원본으로 요청하고 원본응답 저장  if ($http_accept_encoding ~ br) { set $encoding "br, gzip"; break; } if ($http_accept_encoding ~ gzip) { set $encoding "gzip"; break; } if ($http_accept_encoding = "") { set $encoding "gzip"; break; } proxy_ignore_headers Vary ; proxy_cache_key $host$uri$is_args$args$encoding; gunzip on; proxy_set_header Accept-Encoding "$encoding";  (테스트) ..

nginx 2024.04.29

accept-encoding nomalization

압축된 Contents를 Caching 하는 NGINX Proxy의 동작 a. Accept-Encoding을 cache key에 넣지 않아도 캐쉬 키가 달라짐(Vary 문제 해결)proxy_ignore_headers Vary; 설정으로 "accept-encoding: br, gzip" 요청도 br로 HIT됨Vary 해더를 무시하지 않으면 Accept-Encoding이 조금만 달려져도 별도의 Cache Key로 판단 MISS발생(참고 자료) https://www.fastly.com/blog/best-practices-using-vary-header --> proxy_ignore_headers Vary; 로 응답해더에서 Vary를 제거 시 HIT됨# curl relay/1.json -IHTTP/1.1 20..

nginx 2024.04.29

nginx gzip, brotli (ngx_gzip, ngx_brotli) 설정

1. 원본에 Accept-Encoding에 따라 동적으로 압축해 컨텐츠를 설정 추가(원본설정) gzip, br 압축을 동적으로 처리 # gzip config gzip on; gzip_types application/vnd.apple.mpegurl text/plain text/css application/json application/x-javascript text/javascript; gzip_min_length 100; gzip_vary on; gzip_http_version 1.1; gzip_buffers 16 8k; gzip_comp_level 4; # brotli config brotli on; brotli_types appl..

nginx 2024.04.29

How to purge the Nginx cache

Nginx 에서 cache된 contents를 삭제하는 방법은 크게 3가지 정도가 가능하다. 1. cli로 삭제하는 방법 2. bypass 방법으로 삭제하는 방법 3. nginx-cache-purge 모듈로 삭제하는 방법 1. cli 명령어로 삭제 https://kubby72.tistory.com/entry/cli로-nginx-cache-file찾기 cli로 nginx cache file 찾기, 삭제 및 TTL변경 https://kubby72.tistory.com/entry/nginx-cache-key설정 에서 nginx에서 cache file을 저장하는 logic을 설명하였다. 이번에 간단한 script를 통해 해당 파일을 찾고 이를 삭제, 변경하는 방법에 대해 설명하고자 합니 kubby72.tisto..

nginx 2023.06.19
반응형