3

I'm using nginx 1.9.9 as a proxy for Gravatar (drops the waiting time for an avatar from 300ms to 15ms ). However, the cache expires in just a few minutes while I specified it to expire in 7 days. In just a few minutes I receive the header X-Proxy-Cache: EXPIRED.

The configuration is as follows:

proxy_cache_path /var/www/gravatar-cache levels=1:2 keys_zone=gravatar:8m inactive=7d use_temp_path=off max_size=1000m;
proxy_cache_key "$scheme$request_method$host$request_uri";

server {
    listen 443 ssl http2;
    server_name [hidden];

    access_log off;

    ssl_certificate [hidden];
    ssl_certificate_key [hidden];

    location /avatar/ {
        expires 365d;
        proxy_cache gravatar;
        proxy_cache_valid any 7d;
        proxy_pass https://secure.gravatar.com;
        proxy_ignore_headers Cache-Control;
        proxy_hide_header link;
        proxy_hide_header source-age;
        proxy_hide_header content-disposition;
        proxy_hide_header via;
        proxy_hide_header x-varnish;
        proxy_hide_header accept-ranges;
        proxy_hide_header last-modified;
        add_header Cache-Control public;
        add_header X-Proxy-Cache $upstream_cache_status;
    }
}

Is there something wrong with the configuration?

Thanks!

2
$ curl -vv https://en.gravatar.com/userimage/...jpeg -o /dev/null 2>&1 | egrep 'Expires|Cache-Control'
< Expires: Wed, 23 Dec 2015 20:17:02 GMT
< Cache-Control: max-age=300

I think it respects the Expires header.

1
  • Yep, this is the answer. Updating proxy_ignore_headers works
    – Harmen
    Dec 23 '15 at 20:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.