PHP-FPM no cache
Maxim Dounin
mdounin at mdounin.ru
Mon Jul 4 12:59:59 MSD 2011
Hello!
On Mon, Jul 04, 2011 at 02:11:11AM -0500, HTF wrote:
> Hello,
>
> I've enabled caching on php scripts as below but it looks like the
> server is not caching at all:
>
> http {
> fastcgi_cache_path /tmp/cache levels=1:2
> keys_zone=tmp:10m
> inactive=5m;
>
> server {
> location / {
> ...
> fastcgi_cache tmp;
> fastcgi_cache_valid any 1h;
> fastcgi_cache_min_uses 1;
> ...
> }
> }
> }
>
> - but the caching directory is totally empty (nginx has write privileges
> as it was created by nginx itself during reload)
> - I haven't noticed any performance improvements by running apache
> benchmark from different machine
Check your php responses, most likely they disable cache: nginx
honors Cache-Control, Expires headers, and additionally it will
disable cache if it sees Set-Cookie header in response. This
behaviour may be overwritten if desired with
fastcgi_cache_ignore_headers directive, see here:
http://wiki.nginx.org/HttpFcgiModule#fastcgi_ignore_headers
Note though that it's not generally safe as it may cause private
pages (and/or cookies) to be cached and returned to other clients.
Handle with care.
Maxim Dounin
More information about the nginx
mailing list