expires off not applying

Igor Sysoev is at rambler-co.ru
Fri Apr 20 11:01:28 MSD 2007


On Mon, Apr 16, 2007 at 09:20:46PM -0500, Erik Karulf wrote:

> Hello All!
> I am relatively new nginx user (~ 3 months), a convert from the lighttpd
> camp.
> I have been very happy with the elegance and power behind nginx and I am in
> the process of converting all of the servers in our cluster to
> nginx/apache/mongrel (from lighttpd and scgi)
> 
> Anyway, here is my problem.
> The environment is FreeBSD 6.2 running on AMD 64
> I have nginx 0.5.11 setup to forward PHP requests to apache 1.3 (bound to
> 127.0.0.1:8080)  while serving static files locally using sendfile(2)
> 
> Nginx seems to be modifying the expiration and cache control headers when I
> go to /, yet eerily enough it leaves them alone if you go to /index.php.
> Here are the associated http response headers:
> 
> For /
>  Server    nginx/0.5.11
>  Date    Mon, 16 Apr 2007 13:04:12 GMT
>  Content-Type    text/html; charset=ISO-8859-1
>  Transfer-Encoding    chunked
>  Connection    keep-alive
>  X-Powered-By    PHP/5.2.1
>  Expires    Wed, 16 May 2007 13:04:12 GMT
>  Cache-Control    max-age=2592000
>  Pragma    no-cache
>  Content-Encoding    gzip
> 
> For /index.php
>  Server    nginx/0.5.11
>  Date    Mon, 16 Apr 2007 13:05:14 GMT
>  Content-Type    text/html; charset=ISO-8859-1
>  Transfer-Encoding    chunked
>  Connection    keep-alive
>  X-Powered-By    PHP/5.2.1
>  Expires    0
>  Cache-Control    private, post-check=0, pre-check=0, max-age=0
>  Pragma    no-cache
>  Content-Encoding    gzip
> 
> I have attached my nginx.conf below. Also if you have any optimization
> recommendations, please let me know.
> Thanks for the help!
> 
> -Erik Karulf
> 
> nginx.conf>>EOF
> user  www;
> worker_processes  1;
> #pid        logs/nginx.pid;
> 
> events {
>  worker_connections  8192;
>  use kqueue;
> }
> 
> 
> http {
>  include       mime.types;
>  default_type  application/octet-stream;
>  access_log        off;
>  error_log         off;
>  sendfile          on;
>  tcp_nopush        on;
>  tcp_nodelay       on;
> 
>  keepalive_timeout 65;
>  server_names_hash_bucket_size 128; # this seems to be required for vhosts
> 
>  gzip              on;
>  gzip_min_length   1100;
>  gzip_buffers      4 8k;
>  gzip_http_version 1.0;
>  gzip_comp_level   2;
>  gzip_proxied      any;
>  gzip_types        text/plain text/html text/css application/x-javascript
> text/xml application/xml application/xml+rss text/javascript;
> 
>  proxy_redirect           off;
>  proxy_set_header         Host $host;
>  proxy_set_header         X-Real-IP $remote_addr;
>  proxy_set_header         X-Forwarded-For $proxy_add_x_forwarded_for;
>  client_max_body_size     10m;
>  client_body_buffer_size  128k;
>  proxy_connect_timeout    90;
>  proxy_send_timeout       90;
>  proxy_read_timeout       90;
>  proxy_buffer_size        4k;
>  proxy_buffers            4 32k;
>  proxy_busy_buffers_size  64k;
>  proxy_temp_file_write_size  64k;
> 
> 
>  # http://forums.example.com <http://forums.penny-arcade.com/>
>  server {
>     listen         80;
>     server_name    forums.example.com <http://forums.penny-arcade.com/>;
> 
>     location / {
>        root   /www/forums.example.com/ <http://arcade.com/>;
>        index  index.html index.htm index.php;
> 
>        if ($request_filename !~* "^.+.(php|php3)$") {
>           root   /www/forums.example.com/ <http://arcade.com/>;
>           expires    30d;
>           break;
>        }
>        expires    off;
>        proxy_pass http://127.0.0.1:8080/;
>     }
> 
>     location = /clear.gif {
>        empty_gif;
>        expires     30d;
>     }
>  }
> }
> EOF

You should use

  server {
     listen         80;
     server_name    forums.example.com;
 
     location / {
        root   /www/forums.example.com;
        index  index.html index.htm index.php;
        expires    30d;
     }

     location ~ .\.(php|php3)$ {
        proxy_pass http://127.0.0.1:8080/;
        expires    off;
     }
 
     location = /clear.gif {
        empty_gif;
        expires     30d;
     }
  }


-- 
Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list