Notice
Recent Posts
Recent Comments
Link
«   2024/07   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

MEGOLANG

Edge - Relay 간의 Cache 상태 나타내기 본문

메모 메모

Edge - Relay 간의 Cache 상태 나타내기

MEGOLANG 2024. 5. 30. 11:27
map $upstream_cache_status $cache_status {
  'HIT' 'HIT';
  default $upstream_http_x_cache_status;
}

server {
  server_name edge;
  proxy_cache cache_1;
  proxy_cache_key $host$uri;
  proxy_cache_valid 200 206 301 302 10s;
  add_header X-Cache-Status $cache_status;
  proxy_hide_header X-Cache-Status;
  proxy_set_header Host relay;
  location / {
    proxy_pass http://relay;
  }
}

server {
  server_name relay;
  proxy_cache cache_1;
  proxy_cache_key $host$uri;
  proxy_cache_valid 200 206 301 302 10s;
  add_header X-Cache-Status $upstream_cache_status;
  proxy_hide_header X-Cache-Status;
  proxy_set_header Host origin;
  location / {
    proxy_pass http://origin;
  }
}

내 값이 HIT가 아니면, 윗 relay의 값을 참조하게 설정했다.

마지막 relay는 upstream 값이 없기에, 무조건 기본 값으로 넣어야한다.

반응형