1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Nginx not caching when Vary header not ignored

Discussion in 'Nginx' started by Aventador2016, Nov 9, 2016.

  1. #2
    Hi all,

    First off. I don't have much experience with Nginx.

    I'll get straight to the point though;

    Nginx config:
    user www-data;
    worker_processes auto;
    pid /run/nginx.pid;
    events {
    worker_connections 2048;
    multi_accept on;
    }
    http {
    proxy_cache_path /var/nginx_cache levels=1:2 keys_zone=STATIC:10m inactive=24h max_size=10g;

    upstream server {
    server blabla (It is correct though, privacy reasons etc);
    }
    server {
    listen 80;
    server_name (blabla);
    location / {
    gzip on;
    gzip_disable "MSIE [1-6]\.(?!.*SV1)";
    gzip_http_version 1.1;
    gzip_min_length 500;
    gzip_vary on;
    gzip_proxied any;
    gzip_types
    application/atom+xml
    application/javascript
    application/json
    application/ld+json
    application/manifest+json
    application/rss+xml
    application/vnd.geo+json
    application/vnd.ms-fontobject
    application/x-font-ttf
    application/x-web-app-manifest+json
    application/xhtml+xml
    application/xml
    font/opentype
    image/bmp
    image/svg+xml
    image/x-icon
    text/cache-manifest
    text/css
    text/plain
    text/vcard
    text/vnd.rim.location.xloc
    text/vtt
    text/x-component
    text/x-cross-domain-policy
    text/js
    text/xml
    text/javascript;


    add_header X-Cache-Status $upstream_cache_status;
    proxy_cache STATIC;
    proxy_set_header Host $host;
    proxy_ignore_headers Vary; <- When this enabled, all html pages will cache. If I remove this line, everything but HTML pages are being cached.
    proxy_cache_key $host$uri$is_args$args;
    proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;
    proxy_pass blabla;

    }



    }

    }


    I would like that every HTML page gets cached by Nginx even when Vary-headers are being sent by the origin server. Why does Nginx not cache HTML pages when Vary-headers aren't being ignored?

    I hope you have all the information you need here. Let me know if you need more.
     
    Aventador2016, Nov 9, 2016 IP