title: How to Add Expires headers on nginx
body: <p>According to GTMetrix:</p>
  
  <p>There are 6 static components without a far-future expiration date.</p>
  
  <pre><code>http://linuxedgr.disqus.com/recent_comments_widget.js?num_items=5&amp;hide_mods=0&amp;hide_avatars=0&amp;avatar_size=32&amp;excerpt_length=100
  http://s7.addthis.com/js/300/addthis_widget.js#pubid=ra-548e3c553a19ddf3
  http://fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,400,700
  http://www.google-analytics.com/ga.js
  http://a.disquscdn.com/count.js
  http://linuxedgr.disqus.com/count-data.js?1=egkatastasi-tou-nginx&amp;1=eisagogi-ston-nginx&amp;1=new-dedicated-server-in-da-house-me-5-euro&amp;1=o-epimenon-nika&amp;1=pos-mporo-na-kano-encrypt-kai-decrypt-arxeia-xrismopoiontas-to-openssl-toolkit&amp;1=pos-sindeo-ena-domain-apo-tin-IPHost-me-tin-ip-tou-server-mou
  </code></pre>
  
  <p>At my  /etc/nginx/vhosts.d/www.linuxed.gr.conf</p>
  
  <pre><code>server {
      listen 80;
  
          # Δώσε το absolute path που εχεις τα αρχεία του website
      root /var/www/html/linuxed;
  
      # Όριστε το index file
      index index.html index.html index.php;
  
      # Δώσε το όνομα του domain και το alias
      # τα οποια πρεπει να τα εχει δηλώσει και στο /etc/hosts
      server_name www.linuxed.gr linuxed.gr;
  
          # Συμπίεση 
          gzip on;
          gzip_disable "msie6";
          gzip_comp_level 6;
          gzip_min_length  1100;
          gzip_buffers  16 8k;
      gzip_http_version 1.1;
          gzip_proxied     any;
      gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;        
  
      # specify a vary: accept-encoding header
          gzip_vary on;   
  
      # Όριστε μία 404 page
          error_page  404              /error-404.html;
          location = /error-404.html {
          root   /var/www/html/linuxed/;
          }  
  
  
          # redirect server error pages to the static page /50x.html
      #
      error_page   500 502 503 504  /50x.html;
          location = /50x.html {
          root   /usr/share/nginx/html/;
          }
  
          # Disable favicon.ico logging
          location = /favicon.ico {
              log_not_found off;
              access_log off;
          }
  
          # Allow robots and disable logging
          location = /robots.txt {
              allow all;
              log_not_found off;
              access_log off;
          }
  
      ############################
      # Leverage browser caching #
      ############################
      location ~*  \.(jpg|jpeg|png|gif|ico|css|js)$ {
              expires max;
              log_not_found off;
          add_header Pragma public;
              add_header Cache-Control "public";
          } 
  
      # Deny access to htaccess and htpasswd files
          location ~ /\.ht {
              deny  all;
          }
  }
  </code></pre>
  
  <p>Also here's my /etc/nginx/nginx.conf</p>
  
  <pre><code>    user nginx;
  worker_processes  4;
  
  error_log  /var/log/nginx/error.log;
  
  pid        /var/run/nginx.pid;
  
  events {
      worker_connections  1024;
      use epoll;
  }
  
  
  http {
      include       mime.types;
      default_type  application/octet-stream;
      types_hash_max_size 2048;   
  
      log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                        '$status $body_bytes_sent "$http_referer" '
                        '"$http_user_agent" "$http_x_forwarded_for"';
  
      access_log off;
  
      # Tcp_nopush causes nginx to attempt to send its HTTP response head in one packet, 
      # instead of using partial frames. This is useful for prepending headers before
      #  calling sendfile or for throughput optimization.
      tcp_nopush on;
  
      # don't buffer data-sends (disable Nagle algorithm). Good for sending frequent
      # small bursts of data in real time.
      tcp_nodelay on; 
  
      sendfile        on;
  
      # allow the server to close the connection after a client stops responding. 
      #Frees up socket-associated memory.
      reset_timedout_connection on;
  
      gzip on;
      gzip_disable "msie6";
  
      client_body_buffer_size 10k;
      client_header_buffer_size 1k;
      client_max_body_size 8m;
      large_client_header_buffers 2 1k;
  
      client_body_timeout 12;
      client_header_timeout 12;
      keepalive_timeout 15;
      send_timeout 10;
  
      include conf.d/*.conf;
      include vhosts.d/*.conf;
  
  
  }
  </code></pre>
  
  <p>I think my configuration is quite right. How ever I am getting this message at GTMetrix website. How can I fix that?</p>