Welcome! Log In Create A New Profile

Advanced

Re: Caching + Error_code inefficiences

August 25, 2009 01:05AM
Sorry about the partial repost. I misclicked the POST button early on and ran into the edit restrictions. Disregard the top.

Consider:

[code]
fastcgi_cache_path storage/cache levels=2:2 keys_zone=cacheresp:50m inactive=25m max_size=2000M;
fastcgi_temp_path storage/temp/;
fastcgi_cache_valid any 10s;

location / {
root html;
index index.html;

fastcgi_pass unix:/tmp/php-fcgi.socket
include fastcgi_params;

[b]fastcgi_cache cfcheckresp;[/b]

[b]error_page 404 = @backend;[/b]
}

location @backend {
proxy_pass http://127.0.0.1:8070;
}
[/code]

The idea is that if fastcgi returns a 404 then the backend handles the request. The backend's response should never be cached. This part works great. What doesn't... is that the 404 is never cached (the fastcgi script is hardcoded to always return "Cache-Control: max_age=5"). Fastcgi is consulted again and again when a 404 is hit. If any other code is hit it caches just fine for the full 5 seconds. It would be great if the 404 response was cached by nginx. Any thoughts on accomplishing this? Am I missing something?

By the way, the same goes if you use try_files() in place of error_page(). And I believe the same happens when a x-accel-redirect at the fastcgi level is issued.



Edited 2 time(s). Last edit at 08/25/2009 01:06AM by icqheretic.
Subject Author Posted

Caching + Error_code inefficiences

icqheretic August 25, 2009 12:47AM

Re: Caching + Error_code inefficiences

icqheretic August 25, 2009 01:05AM

Re: Caching + Error_code inefficiences

Maxim Dounin August 25, 2009 08:06AM

Re: Caching + Error_code inefficiences

icqheretic August 25, 2009 12:19PM

Re: Caching + Error_code inefficiences

Maxim Dounin August 25, 2009 12:46PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 326
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready