Skip to content

Commit 4c47152

Browse files
committed
config: 정적에셋 캐싱 설정 추가
issues: #1
1 parent 3cd31c4 commit 4c47152

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

nginx.conf

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ http {
1414
include /etc/nginx/mime.types;
1515
default_type application/octet-stream;
1616

17+
# 캐시 설정
18+
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=STATIC_CACHE:10m max_size=1g inactive=60m use_temp_path=off;
19+
1720
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
1821
'$status $body_bytes_sent "$http_referer" '
1922
'"$http_user_agent" "$http_x_forwarded_for"';
@@ -118,5 +121,24 @@ http {
118121
proxy_read_timeout 86400s;
119122
proxy_send_timeout 86400s;
120123
}
124+
125+
location ~* \.(js|css|png|jpg|jpeg|webp|gif|svg|ico|woff|woff2|ttf)$ {
126+
proxy_pass http://react_app; # 리액트 앱으로부터 정적 파일 제공
127+
proxy_set_header Host $host;
128+
proxy_set_header X-Real-IP $remote_addr;
129+
130+
# 서버 측 캐싱 설정
131+
proxy_cache STATIC_CACHE;
132+
proxy_cache_valid 200 302 60m;
133+
proxy_cache_valid 404 1m;
134+
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
135+
proxy_cache_revalidate on;
136+
proxy_cache_min_uses 1;
137+
proxy_cache_lock on;
138+
139+
expires 60m;
140+
add_header Cache-Control "public, immutable, no-transform, max-age=3600";
141+
add_header X-Cache $upstream_cache_status;
142+
}
121143
}
122144
}

0 commit comments

Comments
 (0)