Le 20/12/2019 à 15:53, Aleksandar Lazic a écrit :
Hi.

Luckly that haproxy 2.1 have now the feature of fcgi proto it's now time to move
from nginx to haproxy for the loadbalancing part for me.

There are several features from nginx conf which I would like to port to haproxy
conf therefore I need some help ;-)

nginx offers a quite good caching feature like "fastcgi_cache_path". I know that
haproxy cache is only in memory. Have anyone a suggestion what's the "best" way
to cache the response from the fcgi backend?

http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_cache_path

That's the config values from nginx.

```
fastcgi_cache_path /opt/sde/nginx/fastcgi_cache_www levels=1:2 use_temp_path=off
keys_zone=www:256m max_size=256m;
fastcgi_cache_key "$scheme$host$request_uri$is_args$args";

fastcgi_cache_revalidate on;
fastcgi_cache_valid any 30s;
fastcgi_cache_use_stale error timeout updating http_500 http_503;
fastcgi_cache_lock on;

```

I know that there is nuster but have not yet 2.1 in use.


Hi Aleks,

If the fcgi response is cacheable, you can use the HAProxy cache, just like for any other HTTP/1.1 response. The fcgi and the cache are two orthogonal feature. You may use a dedicated cache for fcgi response, with specifics max-age and max-object-size. About the "best" way to cache fcgi responses, it really depends on your application. IMHO, it is your scripts responsibility to set the right "Cache-Control" header.

Regards,
--
Christopher Faulet

Reply via email to