FastCGI_Cache with Apache-Nginx

johannes

Verified User
Joined
Feb 18, 2007
Messages
223
Hi,

is it possible to use FastCGI_Cache when using Nginx-Apache (proxied)? I got contradictory answers so far.
According to an article here https://www.ryadel.com/en/cache-website-nginx-fastcgi-centos-7-php-fpm/

"FastCGI-Cache is currently considered the most efficient way to implement a dynamic cache mechanism in front of our web server with Nginx: that web server can be Nginx itself or another web server that Nginx will “proxy” by catching all the incoming requests, routing them to the upstream PHP-FPM server, get the resulting HTTP responses and return them to the caller."

.. it should be possible, as Nginx - even as proxy - forwards the requests itself to PHP-FPM.
Can anybody confirm that?

Thank you!
 

johannes

Verified User
Joined
Feb 18, 2007
Messages
223
Ok i got it. Technically its possible, answer from nginx team: "it’s possible to access php-fpm from the reverse proxy and use fastcgi_cache there"
.. but it makes no sense if using apache-nginx combination for compatibility with .htaccess, as with direct forwarding requests from nginx to php-fpm, this feature would be lost and so it would be no difference than using pure nginx.
Problem cleared.
 

zEitEr

Super Moderator
Joined
Apr 11, 2005
Messages
13,853
Location
GMT +7.00
and how it's done?
I didn't see any guide for this subject in DA

There is no specific guide for Directadmin, as if you are going to use Proxy or FastCGI Cache with NGINX, all the configurations are the same.

1. Considers a system of templates in Directadmin. So you need to modify templates and add your directives for caching to start working.

For example: https://www.nginx.com/blog/benefits-of-microcaching-nginx/

2. You will work with the default server location / only.

3. Then add nginx_proxy_buffering=1 to directamin.conf

See: https://www.directadmin.com/features.php?id=1643 and https://help.poralix.com/articles/nginx-does-not-cache-data-on-directadmin-server
 

zEitEr

Super Moderator
Joined
Apr 11, 2005
Messages
13,853
Location
GMT +7.00
The best way to learn it is to give it a try ;)

Depending on what you are going to cache and for how long.... how much does it matter that it will take a page to load 10 seconds for the first time, if then it will be delivered from a cache within 1 second? Did you hear about cache warming up? If cache has been warmed up before that, then it will be directly returned, so it would be much faster response.

If there are pages that you don't need to cache, then you might consider to add new locations into ngnx with disabled proxy buffering.

If you hesitate to add new custom location into nginx, then you might consider adding Varnish between nginx and apache, and try your luck with Varnish.
 
Top