conditional cache

paul2791 nginx-forum at
Thu Sep 2 19:02:34 MSD 2010

Thats brilliant, thanks
Would proxy_pass be considered as a rewrite and safe within an IF as i
use it a lot to bypass cache?

Also, 418 is great code, had never seen that before. I do have some
logic elsewhere in my conf where i have more than two ifs. Does Nginx
allow the use of nondefined codes? 419 for instance? so i could have

location / {
error_page 418 = @cache1;
error_page 419 = @cache2;

if (...needtoshowcache1...) {
return 418;
if (...needtoshowcache2...) {
return 419;

proxy_cache cache3;

location @cache1 {
proxy_cache cache1;
location @cache2 {
proxy_cache cache2;

Ive got as far as testing the error_page 419 =@cache2 ; line and nginx
didn't choke on that, but haven't tested the actual return yet

And yes, all of this would be easier of the developers set expires in
backend, but until they do, im using nginx to make sure our site flies
as fast as it can no matter how slow their code is

Posted at Nginx Forum:,126105,126361#msg-126361

More information about the nginx mailing list