1

I'm trying to optimize my server to consume less resources as possible and increase overall performance. In my site I don't see a need to recompute same requests for users or guests every time. The site is powered by nginx, I enabled fastcgi_cache rules:

fastcgi_cache_path /etc/nginx/cache levels=1:2 keys_zone=MYAPP:250m inactive=60m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
location ~ \.php$ {
...
                fastcgi_cache MYAPP;

                fastcgi_cache_valid  200 301 302 15m;
                fastcgi_cache_use_stale error timeout updating invalid_header http_500 http_503;
                fastcgi_cache_min_uses 1;
                fastcgi_cache_lock on;
                fastcgi_cache_bypass $skip_cache;
                fastcgi_no_cache $skip_cache;
                add_header X-FastCGI-Cache $upstream_cache_status;
        }

I need to also efficiently cache dynamic and static assets for logged in users too, to optimize my systems further. The idea is to combine ever wordpress_logged_in cookies in singleton cookie, for example cookie_memberships. And pass that HTTP parameter in fastcgi_cache_key “$scheme$request_method$host$request_uri$cookie_memberships”; rule. How can I do that with PHP?

2
  • Have you considered that the WordPress nonces are uncacheable? Even if you successfully cache a page based on a logged in user, if the page uses forms, it will break. Anyway, is there multiple wordpress_logged_in cookie? Usually, there is one. Commented Jun 14, 2022 at 11:40
  • I don't really know if wordpress_logged_in cookie is created for each user. If I could partially cache that cookie, it'd help reduce server overload.
    – AtomX
    Commented Jun 14, 2022 at 12:16

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.