0

I have enabled microcache + static cache + pagespeed in my nginx domain conf file. My server is behind cloudflare. When I inspect element on browser, I only see br-cache-status HIT for root path "/" and all other files show cache HIT by cloudflare with cf-cache-status HIT.

Also pagespeed module configuration seems not to be applying on website.

When I test on local server (which is not behind cloudflare) with same config then everything seems to work perfect. For css and js file, I can see cache-control header set to 600s.

Centos 6 / nginx version: nginx/1.14.2

 set $skip_cache 0;

    if ($request_method = POST) {
        set $skip_cache 1;
    }
    if ($query_string != "") {
        set $skip_cache 1;
    }
    if ($request_uri ~* "/wp-admin/|/xmlrpc.php|/feed/|sitemap(_index)?.xml") {
        set $skip_cache 1;
    }
    if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
        set $skip_cache 1;
    }



     location ~ \.php$ {
        try_files $uri = 404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/opt/remi/php56/run/php-fpm/php-fpm.sock;
        fastcgi_cache microcache;
        # fastcgi_cache_key $scheme$host$request_uri$request_method;
        fastcgi_cache_key $host$uri$is_args$args;
        fastcgi_cache_valid 200 301 302 10m;
        fastcgi_cache_bypass $skip_cache;
        fastcgi_no_cache $skip_cache;
        fastcgi_cache_revalidate on;
        fastcgi_cache_background_update on;
        fastcgi_cache_use_stale updating error timeout invalid_header http_500;
        add_header BR-Cache-Status $upstream_cache_status;
        fastcgi_pass_header Set-Cookie;
        fastcgi_pass_header Cookie;
        fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
        fastcgi_hide_header Set-Cookie;
        fastcgi_index index.php;
        include /etc/nginx/fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_buffers 16 16k;
        fastcgi_buffer_size 32k;
        fastcgi_connect_timeout 60s;
        fastcgi_send_timeout 60s;
        fastcgi_read_timeout 60s;
    }

    location ~* .(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
        expires 10m;
        access_log off;
    }

P.S. I am using cloudflare only for SSL.

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.