Nginx FastCGI : X-Fastcgi-Cache: MISS

Discussion in 'Installation/Configuration' started by EckyBrazzz, Feb 20, 2017.

  1. EckyBrazzz

    EckyBrazzz New Member

    Hi,
    I am trying to get FastCGI to work but on every site I get X-Fastcgi-Cache: MISS and the cache directory keeps empty
    A simple curl -I gives me
    Code:
    [email protected]:/etc/nginx# curl -I https://some.domain
    HTTP/1.1 200 OK
    Server: nginx/1.11.9
    Content-Type: text/html; charset=UTF-8
    Connection: keep-alive
    Vary: Accept-Encoding
    X-Powered-By: PHP/7.1.1
    Set-Cookie: qtrans_front_language=en; expires=Tue, 20-Feb-2018 14:40:00 GMT; Max-Age=31536000; path=/; secure
    Link: <https://some.domain/wp-json/>; rel="https://api.w.org/"
    X-Fastcgi-Cache: MISS
    Date: Mon, 20 Feb 2017 14:40:00 GMT
    X-Page-Speed: 1.12.34.2-0
    Cache-Control: max-age=0, no-cache
    
    My nginx.conf, the last part has
    Code:
     ##
            # Virtual Host Configs
            ##
    
            pagespeed on;
            pagespeed FileCachePath /var/ngx_pagespeed_cache;
    
            include /etc/nginx/conf.d/*.conf;
            include /etc/nginx/sites-enabled/*;
    
            fastcgi_cache_path /etc/nginx/cache levels=1:2 keys_zone=CZONE:100m inactive=60m;
            fastcgi_cache_key "$scheme$request_method$host$request_uri";
            fastcgi_ignore_headers X-Accel-Expires Expires Cache-Control;
    
            index index.php;
    
    }
    
    The /etc/nginx/cache has as owner www:data and my vhost is like this
    Code:
    [...]
         location @php {
                    try_files $uri =404;
                    include /etc/nginx/fastcgi_params;
                    fastcgi_pass unix:/var/lib/php7.0-fpm/web5.sock;
                    fastcgi_index index.php;
                    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                    fastcgi_intercept_errors on;
                    fastcgi_ignore_client_abort off;
                    fastcgi_connect_timeout 60;
                    fastcgi_send_timeout 90;
                    fastcgi_read_timeout 90;
                    fastcgi_buffer_size 128k;
                    fastcgi_buffers 4 256k;
                    fastcgi_busy_buffers_size 256k;
                    fastcgi_temp_file_write_size 256k;
                    fastcgi_cache CZONE; # The name of the cache key-zone to use
                    fastcgi_cache_valid     200 301 302  1h; # What to cache: 'code 200' and 'code 302' responses, for an hour
                    fastcgi_cache_valid     404     1m;
                    fastcgi_cache_min_uses  2;
                    fastcgi_cache_methods GET HEAD; # What to cache: only GET and HEAD requests (ot POST)
                    add_header X-Fastcgi-Cache $upstream_cache_status; # Allow us to see if the cache was HIT, MISS, or BYPASSED inside a browser's Inspector panel
                    fastcgi_cache_bypass $no_cache; # Dont pull from the cache if true
                    fastcgi_no_cache $no_cache; # Dont save to the cache if true
                    fastcgi_keep_conn on;
            }
    
    [...]
    my /etc/fstab
    Code:
    LABEL=cloudimg-rootfs   /        ext4   defaults,discard,usrjquota=quota.user,grpjquota=quota.group,jqfmt=vfsv0  0 1
    tmpfs /etc/nginx/cache tmpfs defaults,size=2G 0 0
    
    The only strange things I noticed are in Bold, One is With PHP7.1.1 and the other with PHP7. I can't find where it goes wrong. I had it in the past (other installation, same config) working.
    Who can give me an answer?

    Forgotten : I added to /etc/nginx/sites-enabled/default
    Code:
    set $no_cache 0;
           if ($request_method = POST) {
                   set $no_cache 1;
           }
           if ($query_string != "") {
                   set $no_cache 1;
           }
     
    Last edited: Feb 20, 2017
  2. EckyBrazzz

    EckyBrazzz New Member

    DonĀ“t know how, but it's working again. But on a clean install of WordPress.

    [email protected]:/usr/local/ispconfig# df -ah | grep tmpfs
    tmpfs 799M 50M 749M 7% /run
    tmpfs 3.9G 0 3.9G 0% /dev/shm
    tmpfs 5.0M 4.0K 5.0M 1% /run/lock
    tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
    tmpfs 2.0G 48K 2.0G 1% /etc/nginx/cache
    tmpfs 799M 0 799M 0% /run/user/1000
     

Share This Page