# Cache zone for ui-dashboard.gnerim.ru /api/* and /map/api/* upstreams.
# Lives in /etc/nginx/conf.d/ because proxy_cache_path is only valid in the
# http {} context, not inside server {}.
#
# Why we need it: flights.test.aeroflot.ru's WAF has a per-source-IP rate
# limit (~25-30 fresh TCP connections per window) that the parallel e2e
# burst trips. Caching read-only GETs by the customer-facing nginx layer
# absorbs the burst — only one request per (URI, window) reaches the WAF.

proxy_cache_path /var/cache/nginx/flights-api
                 levels=1:2
                 keys_zone=flights_api:10m
                 max_size=200m
                 inactive=30m
                 use_temp_path=off;

# Don't cache upstream responses whose Content-Type is HTML — the upstream
# WAF returns its block page ("Доступ к сайту временно ограничен") with
# HTTP 200 + text/html, and prior to this filter nginx happily cached that
# as a valid 200 for the next 6h, poisoning every subsequent dictionary
# read for the SSR app. Pair with `proxy_no_cache $no_cache_html;` in the
# server block.
map $upstream_http_content_type $no_cache_html {
    ~*text/html  1;
    default      "";
}
