Author Topic: NGINX PHP Microcaching not working  (Read 6087 times)

0 Members and 1 Guest are viewing this topic.

Offline
*
NGINX PHP Microcaching not working
« on: February 20, 2019, 12:15:50 PM »
Hello,

I've been trying setup NGINX PHP Microcaching for a while now but can't get it to work.

I've removed all extra code (for exceptions) and just set the following in vhost conf:

Above server tag:
Code: [Select]
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
fastcgi_cache_path /etc/nginx/cache levels=1:2 keys_zone=microcache:100m inactive=1y max_size=100m;
fastcgi_cache_key "$scheme://$host$request_method$request_uri";

And in location ~ .*\.(php|jsp|cgi|pl|py)?$ block, I have added:
Code: [Select]
# Select which cache to use
fastcgi_cache microcache;
# Cache successful responses for one second, you could also cache redirects here by adding status code 302!
fastcgi_cache_valid any 1s;
fastcgi_cache_lock on;
fastcgi_cache_use_stale updating;
fastcgi_cache_background_update on;
# Show cache status in HTTP headers, useful for debugging
add_header X-Cache $upstream_cache_status;

However the PHP just doesn't seem to cache. I've tried several other options too but to no avail.

My NGINX is a reverse-proxy on Apache set to use PHP-FPM.

Any ideas how I can get microcaching to work?

Offline
*
Re: NGINX PHP Microcaching not working
« Reply #1 on: February 20, 2019, 01:05:38 PM »
for this to work you need to have php-fpm and caching also enabled
VPS & Dedicated server provider with included FREE Managed support for CWP.
http://www.studio4host.com/

*** Don't allow that your server or website is down, choose hosting provider with included expert managed support for your CWP.

Offline
*
Re: NGINX PHP Microcaching not working
« Reply #2 on: February 20, 2019, 01:27:16 PM »
for this to work you need to have php-fpm and caching also enabled
Thank you for your reply.
I am using PHP-FPM indeed.
info.php responds with "Server API  FPM/FastCGI"

Where can I enable caching?
NGINX microcaching should work on its own regardless of PHP caching I think?

Offline
*
Re: NGINX PHP Microcaching not working
« Reply #3 on: February 20, 2019, 06:07:32 PM »
in php-fpm selector you need to have cache enabled, it would work only for static files if not enabled.
VPS & Dedicated server provider with included FREE Managed support for CWP.
http://www.studio4host.com/

*** Don't allow that your server or website is down, choose hosting provider with included expert managed support for your CWP.

Offline
*
Re: NGINX PHP Microcaching not working
« Reply #4 on: February 21, 2019, 06:26:53 AM »
in php-fpm selector you need to have cache enabled, it would work only for static files if not enabled.
In PHP-FPM Selector I am using PHP-FPM 7 and in options I already have zend-opcache selected if that is what you were referring to.
apcu is also installed but memcached isn't.

Can you please clarify which cache you were referring to?