If you do exactly what http://wiki.nginx.org/HttpHeadersModule asks you to do you may still not see Cache-Control and Expires headers in the HTTP response of a page served by your NGINX web server. This may be due to where you place expires directive.
The following is a sample configuration.
01 | server { |
02 | listen 80; |
03 | server_name cppprogramming.chtoen.com; |
04 | expires 1y; #works here |
05 |
06 | location / { |
07 | expires 1y; #does NOT work here |
08 | root /home/ubuntu/repository201207/trunk-cpp/; |
09 | |
10 | ... |
11 | } |
12 | ... |
13 | } |
When the expires directive doesn't work here are the example HTTP response headers:
Connection:keep-alive
Content-Encoding:gzip
Content-Type:text/html
Date:Thu, 02 May 2013 03:32:50 GMT
Server:nginx/0.7.65
Transfer-Encoding:chunked
Vary:Accept-Encoding
X-Powered-By:PHP/5.3.2-1ubuntu4.14
When the expires directive works here are the example HTTP response headers:
Cache-Control:max-age=31536000
Connection:keep-alive
Content-Encoding:gzip
Content-Type:text/html
Date:Thu, 02 May 2013 03:33:38 GMT
Expires:Fri, 02 May 2014 03:33:38 GMT
Server:nginx/0.7.65
Transfer-Encoding:chunked
Vary:Accept-Encoding
X-Powered-By:PHP/5.3.2-1ubuntu4.14
Questions? Let me know!