I have some questions about caching implementation since most of the resources I have found don’t seem to distinguish between NGINX as a reverse proxy or as a “native” web host.
I’ve setup a WordPress server on a LEMP stack (so NGINX as a “native” web host) which sits behind a separate NGINX reverse proxy. For caching, I have implemented fastcgi_cache on the server hosting WordPress. My reasoning is that since that server is handling the php anyway, it makes the most sense to cache it here locally since it’s on the same machine. That way, if I get .php request from the reverse proxy on my upstream server, it’s already there and waiting.
1) Is this logic sound/correct or should I still be handling the fastcgi_cache on the reverse proxy?
On my reverse proxy, which is also running NGINX, I have it setup to proxy_pass http traffic to the above WordPress server. I am going to have it browser cache static content (like .js, .css). Additionally, I am planning on having the reverse proxy proxy_cache the HTTP traffic it normally would’ve forwarded to the WordPress upstream. I will exclude certain locations from proxying (/wp-admin/, cookies, etc). My logic is that it makes the most sense to handle the HTTP proxy_cache here since it’s closest to the client.
2) Is this the appropriate way to handle this?
3) Will the requests for .php files still make it through to my WordPress server to be handled by the fastcgi_proxy/fastcgi_cache? My guess/concern is that it wouldn’t since these requests are afterall still HTTP requests.
Tl;dr: I have two NGINX servers: One hosting WordPress and another serving as a reverse proxy. I am planning on proxy_caching on the reverse proxy and fastcgi_caching on the WordPress server. Is this configuration acceptable?
These questions aren’t necessarily just for my specific application but also to help me understand how exactly NGINX is supposed to work. Thanks in advance!