• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.2 [LF Recommendations] MemcacheD BackEnd Other Cache Options?

Bill.D

Active member
#1
Hey All,

I am looking to see if there are any other good options/recommendations for things I should Cache using my BackEnd MemCacheD System.

Here is my current config:
PHP:
$config['cache']['enabled'] = true;
$config['cache']['cacheSessions'] = true;
$config['cache']['backend'] = 'Memcached';
$config['cache']['backendOptions'] = array(
    'compression' => false,
    'servers' => array(
        array(
            // your memcached server IP address X's for Privacy
            'host' => 'xxxxxxxxxxxxxx',
           
            // memcached port
            'port' => 11211,
        )
    )
);
You can see I am currently caching sessions. I tried looking at the Zend documentation that I was linked to via Xenforo.com/help/cache/ but I am afraid it was a bit confusing! Are there any other optimizations I should consider? I already have FastCGI caching on via NGINX and I have integrated a CDN via these options:
PHP:
$config['externalDataUrl'] = 'http://cdn.xxxxx.com/data';
$config['javaScriptUrl'] = 'http://cdn.xxxxx.com/js';
And I have aslo enabled Gzip via Config.php & NGINX

Thanks for any advice :)
 
#2
ngx_pagespeed can use memcached to cache some things but just used it for 3 days and increase my site with +1second in load with some high cpu load for nginx, I don't recommand to use ngx_pagespeed with xenforo.
What config do you used for FastCGI caching ? Just tried to make it working and failed, can you share it with us ?
 

Bill.D

Active member
#3
Just below this area:

Code:
http {
    include      /etc/nginx/mime.types;
    default_type  application/octet-stream;
I placed This:
Code:
    fastcgi_cache_path  /{DIRECTORY FOR CACHE}  levels=1:2
                      keys_zone={NAME FOR CACHE}:128m
                      inactive=5m;
    fastcgi_cache_key "$scheme$request_method$host$request_uri";
AND in the Server configurations starting with:
Code:
server {
        listen      80;
I put this for the PHP:
Code:
location ~ \.php$ {
            fastcgi_pass  {Usually an IP:PORT OR Unix Socket. I Use a Backend UpStream using Multiple PHP Rendering Systems};
            fastcgi_index index.php;
            fastcgi_cache  {NAME FOR CACHE};
            fastcgi_cache_valid  200 302  30m;
            fastcgi_cache_valid  301      1d;
            fastcgi_cache_valid  any      15m;
            fastcgi_cache_min_uses  1;
            fastcgi_cache_use_stale error  timeout invalid_header http_500;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include /etc/nginx/fastcgi.conf;
I have been slow increasing the cache time to see what is most optimal.. The time you see is just were I am at the moment.. So far people can still post and see the instant results so no interference there.

I also have GZIP enabled on both NGINX & Xenforo.

To date my Cache has only amounted to about 11MB but these are not really high traffic sites. I will be planning on moving a big site soon and will let you know how that goes :)

-Bill
 
Last edited:
#4
Code:
        location ~ \.php$ {
                set $no_cache "";
                if ($query_string ~ ".+") {
                        set $no_cache "1";
                }
                if ($request_method !~ ^(GET|HEAD)$ ) {
                        set $no_cache "1";
                }
                if ($request_uri ~ "nocache") {
                        set $no_cache "1";
                }
                if ($no_cache = "1") {
                        return 405;
                }

                set $memcached_key $host$request_uri;
                memcached_pass    127.0.0.1:11211;
                default_type text/html;
                error_page 404 405 502 = @php;
                expires epoch;
        }

        location @php {
                        try_files $uri =404;
                        include /etc/nginx/fastcgi_params;
                        fastcgi_pass unix:/var/lib/php5-fpm/web1.sock;
                        fastcgi_index index.php;
                        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                        fastcgi_param PATH_INFO $fastcgi_script_name;
                        fastcgi_intercept_errors on;
        }
To store full page in memcache, but i think there need to use some cookie.