Different cache_valid per location

nfn nginx-forum at nginx.us
Fri Jun 15 10:41:57 UTC 2012


Hi,

I'm trying to find the correct way to have different cache times per
location.
The problem I have is that all locations are redirected using try_files
to the same file and then to fastcgi.

I was thinking about something like this, but it doesn't work:

fastcgi_cache_path   /var/cache/nginx/one levels=1:2
keys_zone=one:500m;										 

server {

    location /a {
      fastcgi_cache_valid 200 15m;
      try_files $uri $uri/ /index.php;
    }
	
    location /b {
      fastcgi_cache_valid 200 60m;
      try_files $uri $uri/ /index.php;
    }
 
  ## PHP
  location ~ \.php$ {
    ...
    fastcgi_cache one;
    fastcgi_cache_use_stale error  timeout invalid_header http_500;
    ...
  }
}

How can I archive this?

Thanks

NN

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,227557,227557#msg-227557



More information about the nginx mailing list