Nginx缓存图像的重定向响应(302)

时间:2017-12-19 01:55:30

标签: caching nginx nginx-location nginx-reverse-proxy

我已经将下面的nginx缓存定义为配置。

    location ~* \.(ico|css|js|gif|jpe?g|png)$ {

        proxy_cache folder;
        proxy_cache_min_uses 1;
        proxy_cache_valid 200 60m;
        proxy_hide_header Set-Cookie;
        proxy_ignore_headers Set-Cookie;

        proxy_cache_valid any 0;

        proxy_cache_key $scheme$proxy_host$host$request_uri;
        client_max_body_size 50m;

        proxy_pass http://upstream_folder;

        proxy_http_version 1.1;
        proxy_buffers 4 256k;
        proxy_buffer_size 128k;
        proxy_busy_buffers_size 256k;
        proxy_send_timeout 300s;
        proxy_read_timeout 300s;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $x_forwareded_for;

        keepalive_timeout 5;
    }

我不想缓存非200个请求静态内容,如img / css / js / gif等。

但是对于具有302重定向响应的下面的请求,nginx会缓存它。请告诉我我的ningx配置有什么问题。以及如何避免对图像或任何静态内容进行302响应缓存。

    curl 'https://localhost:9000/hello.jpg' --verbose
    *   Trying localhost....
    * Connected to localhost (ip) port 443 (#0)
    * TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
    > GET /support.jpg HTTP/1.1
    > Host: localhost
    > User-Agent: curl/7.43.0
    > Accept: */*
    > 
    < HTTP/1.1 302 Moved Temporarily
    < Server: nginx/1.8.0
    < Date: Tue, 19 Dec 2017 00:47:51 GMT
    < Content-Type: image/jpeg
    < Content-Length: 0
    < Connection: keep-alive
    < Cache-Control: public, max-age=315358505
    < Expires: Fri, 17 Dec 2027 00:22:56 GMT
    < Location: https://localhost:9000/login.jspa?referer=%252Fhello.jpg&hint=
    < P3P: CP="CAO PSA OUR"
    < X-Frame-Options: SAMEORIGIN
    < X-JVL: D=16190 t=1513642992041808
    < X-Robots-Tag: none

0 个答案:

没有答案
相关问题