title: Using both Varnish and Nginx cache
body: <p>Are there any performance benefits or performance degradation in using both varnish and nginx proxy cache together? I have a magento 2 site running with nginx cache, redis for session storage and backend cache and varnish in front. All on same centos machine. Any inputs or advice please? Below currently used nginx configuration file.</p>
  
  <pre><code># Server globals
  user                    nginx;
  worker_processes        auto;
  worker_rlimit_nofile    65535;
  pid                     /var/run/nginx.pid;
  
  
  # Worker config
  events {
          worker_connections  1024;
          use                 epoll;
          multi_accept        on;
  }
  
  
  http {
      # Main settings
      sendfile                        on;
      tcp_nopush                      on;
      tcp_nodelay                     on;
      client_header_timeout           1m;
      client_body_timeout             1m;
      client_header_buffer_size       2k;
      client_body_buffer_size         256k;
      client_max_body_size            256m;
      large_client_header_buffers     4   8k;
      send_timeout                    30;
      keepalive_timeout               60 60;
      reset_timedout_connection       on;
      server_tokens                   off;
      server_name_in_redirect         off;
      server_names_hash_max_size      512;
      server_names_hash_bucket_size   512;
  
      # Proxy settings
      proxy_redirect      off;
      proxy_set_header    Host            $host;
      proxy_set_header    X-Real-IP       $remote_addr;
      proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_pass_header   Set-Cookie;
      proxy_connect_timeout   90;
      proxy_send_timeout  90;
      proxy_read_timeout  90;
      proxy_buffers       32 4k;
  
  
      # SSL PCI Compliance
      ssl_session_cache   shared:SSL:40m;
      ssl_buffer_size 4k;
      ssl_protocols       TLSv1.1 TLSv1.2 TLSv1.3;
      ssl_prefer_server_ciphers on;
  
      # Error pages
      error_page          403          /error/403.html;
      error_page          404          /error/404.html;
      error_page          502 503 504  /error/50x.html;
  
  
      # Cache settings
      proxy_cache_path /var/cache/nginx levels=2 keys_zone=cache:10m inactive=60m max_size=1024m;
      proxy_cache_key "$host$request_uri $cookie_user";
      proxy_temp_path  /var/cache/nginx/temp;
      proxy_ignore_headers Expires Cache-Control;
      proxy_cache_use_stale error timeout invalid_header http_502;
      proxy_cache_valid any 1d;
  
  
      # Cache bypass
      map $http_cookie $no_cache {
          default 0;
          ~SESS 1;
          ~wordpress_logged_in 1;
      }
  
  
      # File cache settings
      open_file_cache          max=10000 inactive=30s;
      open_file_cache_valid    60s;
      open_file_cache_min_uses 2;
      open_file_cache_errors   off;
  
  
      # Wildcard include
      include             /etc/nginx/conf.d/*.conf;
  }
  </code></pre>