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?
wordpress_logged_in
cookie? Usually, there is one.wordpress_logged_in
cookie is created for each user. If I could partially cache that cookie, it'd help reduce server overload.