• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

Nginx doesn't send expiration headers

PaulS8

New Pleskian
Hello All,

I am migrating a site from apache web server and cannot get nginx header expiration work. This is the part of the server block (testing on a subdomain):

Code:
     server {
        listen 80 default_server;
    	
    	server_name br.mydomain.com;
        server_name www.br.mydomain.com;
        server_name ipv4.br.mydomain.com;
        server_name localhost;
    
        # Path for static files
        root /usr/share/nginx/html;
    
        #Specify a charset
        charset utf-8;
    
        # Custom 404 page
        error_page 404 /404.html;
    
        # cache.appcache, your document html and data
        location ~* \.(?:manifest|appcache|html|xml|json)$ {
          expires -1;
        #  access_log logs/static.log;
        }
    
        # Feed
        location ~* \.(?:rss|atom)$ {
          expires 1h;
          add_header Cache-Control "public";
        }
    
        # Favicon
        location ~* \.ico$ {
          expires 1w;
          access_log off;
    	  add_header Pragma public;
          add_header Cache-Control "public";
        }
    
        # Media: images, video, audio, HTC, WebFonts
        location ~* \.(?:jpg|jpeg|gif|png|ico|gz|svg|svgz|ttf|otf|woff|eot|mp4|ogg|ogv|webm)$ {
          expires 1M;
          access_log off;
    	  add_header Pragma public;
          add_header Cache-Control "public";
        }
        
    	location ~* \.(js|css)$ {
    	  expires 60d;
    	  add_header Pragma public;
    	  add_header Cache-Control "public";
    	}
    	
        # CSS and Javascript
        #location ~* \.(?:css|js)$ {
        #  expires 1y;
        #  access_log off;
        #  add_header Cache-Control "public";
        #}
    
        # opt-in to the future
        add_header "X-UA-Compatible" "IE=Edge,chrome=1";
      }

Nginx restarts OK, no error messages, but it doesn't change header expiration:

Code:
Cache-Control:max-age=604800
Connection:keep-alive
Date:Wed, 27 Nov 2013 22:07:55 GMT
Expires:Wed, 04 Dec 2013 22:07:55 GMT
Last-Modified:Mon, 18 Nov 2013 08:34:10 GMT
Server:nginx
X-Powered-By:PleskLin

What could be wrong here and prevent setting expiration times?

Thanks!
 
You are provide response headers, but you are not provide resource(URI) which you are requesting from server. So it's impossible to say what's wrong with "Expires" headers.

By you config and this response header I assume that it was ico file

because of:

# Favicon
location ~* \.ico$ {
expires 1w;
access_log off;
add_header Pragma public;
add_header Cache-Control "public";
}
 
Back
Top