Opened 3 years ago

Closed 2 years ago

#2189 closed defect (duplicate)

proxy_cache don't work with X-Accel-Redirect response from proxy

Reported by: vsychov@… Owned by:
Priority: major Milestone:
Component: nginx-module Version: 1.19.x
Keywords: cache, proxy, redirect, X-Accel-Redirect Cc:
uname -a: Linux 81dbcaf6fe53 5.10.25-linuxkit #1 SMP Tue Mar 23 09:27:39 UTC 2021 x86_64 Linux
nginx -V: nginx version: nginx/1.19.10
built by gcc 10.2.1 20201203 (Alpine 10.2.1_pre1)
built with OpenSSL 1.1.1i 8 Dec 2020 (running with OpenSSL 1.1.1k 25 Mar 2021)
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/ --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --with-perl_modules_path=/usr/lib/perl5/vendor_perl --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-Os -fomit-frame-pointer -g' --with-ld-opt=-Wl,--as-needed


Hello there,

I found behavior that looks like bug. I have schema that described on this image (

I expect that nginx should cache both steps, response from APP (with X-Accel-Redirect), and response from IMG with static content (or direcly static content), but it's wont work, it cache only response from IMG.

I din't found any menthions in doc's that nginx won't cache X-Accel-Redirect response.

server {
    listen 80;

    set $skip_cache 0;

    location / {
        proxy_cache app;
        proxy_cache_bypass $skip_cache;
        proxy_no_cache $skip_cache;
        proxy_cache_valid 10m;

        proxy_pass http://app;

    location /internal/ {
        proxy_cache images;
        proxy_cache_bypass $skip_cache;
        proxy_no_cache $skip_cache;
        proxy_cache_valid 10m;

        proxy_pass http://img;

Attachments (1)

schema.png (231.3 KB ) - added by vsychov@… 3 years ago.

Download all attachments as: .zip

Change History (2)

by vsychov@…, 3 years ago

Attachment: schema.png added

comment:1 by Maxim Dounin, 2 years ago

Resolution: duplicate
Status: newclosed

Internal redirections via X-Accel-Redirect are not cached. If needed, currently it is possible to cache responses with X-Accel-Redirect by instructing nginx to ignore X-Accel-Redirect and processing X-Accel-Redirect redirections via additional proxying.

Closing this as a duplicate of #407.

Note: See TracTickets for help on using tickets.