It was noticed that caching does not work in NGINX if to try and enable it on a Directadmin server when using NGINX+Apache scheme. Here you can learn why...
By default, NGINX respects the Cache-Control headers from origin servers. It does not cache responses with Cache-Control set to Private, No-Cache, or No-Store or with Set-Cookie in the response header. NGINX only caches GET and HEAD client requests.
These defaults can be overwritten, and it goes out of a scope of this article.
NGINX will not cache responses if proxy_buffering is set to off. It is on by default.
Directadmin since version 1.46 has an option which disables proxy_buffering by default with NGINX+Apache scheme:
nginx_proxy_buffering=0
Thus to get the caching to work you need to enable proxy_buffering in NGINX by changing internal default value of nginx_proxy_buffering to 1 in directadmin.conf:
cd /usr/local/directadmin/conf/ cp -fp directadmin.conf{,~bak} echo "nginx_proxy_buffering=1" >> directadmin.conf
Restart directadmin:
service directadmin restart
and rewrite configs:
cd /usr/local/directadmin/custombuild ./build update && ./build rewrite_confs
Enabling buffering in NGINX will mean that Apache sends all data to NGINX, which stores it in a buffer, which can then disconnect from Apache to let it do other things.
The catch with enabled proxy_buffering is that NGINX doesn't start to send all of the data until Apache has finished sending it to NGINX... meaning the first byte is not sent until NGINX receives the last byte from Apache.