• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

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