Problems with setting max-age header directive

ST smntov at gmail.com
Tue Jun 13 13:46:21 UTC 2017


Hello,

I try to set max-age header using expires, as follows:

location / {
	 # set up max-age header directive for certain file types for proper
caching
	 location ~* \.(?:css|js|ico|gif|jpe?g|png|mp3|mpeg|wav|x-ms-wmv|eot|
svg|ttf|woff|woff2)$ {
	     expires 7d;
	     add_header Cache-Control "public";
	 }

	 location /static_files/ {
	     expires 7d;
	     add_header Cache-Control "public";
	 }
	try_files $uri $uri/ @nc-rewrite;
}

My problem are files that do not have proper extension, but need to
cached and they are located in /static_files/. For some reason
location /static_files/ {} is used according to logs (see bellow), but
max-age/Cahe-Control is not set. Why?

Thank you in advance!

----error.log-----

2017/06/13 16:43:18 [debug] 30872#0: *1 using configuration
"/static_files/"




More information about the nginx mailing list