FastCGI issue on wordpress multisite

Hi, i have FastCGI enabled and its working perfectly on my main site. but for my other sites which is in sub directory multisite setup, FastCGI is caching even the admin area too. i dont understand why FasctCGI is not bypassing sub-directory sites admin area when cache bypass is working for main sites admin area. i have opcache enabled as well. is that might be any issue here?

here is the response header from post page

Request URL:
Request Method:GET
Status Code:200 OK
Remote Address:
Referrer Policy:no-referrer-when-downgrade

Cache-Control:no-cache, must-revalidate, max-age=0
Content-Type:text/html; charset=UTF-8
Date:Tue, 28 Mar 2017 16:17:56 GMT
Expires:Wed, 11 Jan 1984 05:00:00 GMT

and these are my FastCGI config

fastcgi_cache_path /var/run/cache levels=1:2 keys_zone=MYAPP:100m inactive=60m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
add_header X-Cache $upstream_cache_status;
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
        #Cache everything by default
        set $no_cache 0;

        #Don't cache POST requests
        if ($request_method = POST) {
                set $no_cache 1;

        #Don't cache if the URL contains a query string
        if ($query_string != "") {
                set $no_cache 1;

        #Don't cache the following URLs
        if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml") {
                set $no_cache 1;

        #Don't cache if there is a cookie called PHPSESSID
        if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
                set $no_cache 1;

        location / {
                try_files $uri $uri/ /index.php$is_args$args;
                # try_files $uri $uri/ /index.html;
                # try_files $uri $uri/ =404;
        location ~ \.php$ {
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/run/php/php7.0-fpm.sock;
                include fastcgi_params;
                fastcgi_param REQUEST_METHOD $request_method;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_cache MYAPP;
                fastcgi_cache_valid 200 60m;
                fastcgi_cache_bypass $no_cache;
                fastcgi_no_cache $no_cache;

and this is what i have for enabling multi-site

        if (!-e $request_filename) {
                rewrite /wp-admin$ $scheme://$host$uri/ permanent;
                rewrite ^(/[^/]+)?(/wp-.*) $2 last;
                rewrite ^(/[^/]+)?(/.*\.php) $2 last;

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.


As noted in the other thread, please post the full server block, top to bottom. Feel free to change the domain if you’d like, though make sure everything else is verbatim what you’re using.