is caching using a webserver's cache (nginx) useful with elgg?

i notice that the elgg simple cache and system cache focus on the static files and elgg engine.
am i likely to be able to improve the site's performance by using the nginx (or other) cache to further refine the caching?
i'm looking at the info on this page and wondering whether to bother or not:
http://seravo.fi/2013/optimizing-web-server-performance-with-nginx-and-php

i'm using apc opcode cache for php..

presently i am seeing the cpu maxing out even with very low traffic on a VPS.. the RAM does not max out or the hard drive.. the CPU reaches 100% on nearly every page visit! as yet i am unsure why..  i think the cpu is about 2.4 GHz.

any tips?
thanks

  • with a carefully configured caching structure, the same type of performance should be possible from nginx/varnish or any other decent cache as has been seen with gallicache.

    so far i have searched the elgg sourcecode and not seen any evidence of any type of caching approach that uses the standard fields such as 'Cache-Control, Pragma and Expires' in any type of intelligent way.. is that by design for a reason i am not aware of, maybe?
    is memcache intended to deal with all of this for us? (i don't think i have ever got memcache to run correctly).
    when i tested varnish i did increase the speed of page loads quite a lot.

  • Cache control and Expire are in .htaccess. But that is both for local caching.

  • ah right, yes.. so maybe i don't need to change those fields to get nginx to 'hit' it's cache for elgg pages.. and nginx is not caching them for some other reason.. i continue!

  • i am still unclear here on why the javascript cache handling is incomplete in elgg core..
    i thought that if i used the minifier plugin and activate both elgg caches, that the javascript files would at least be concatonated and have an appropriate cache tag applied to them..
    from what i am seeing that is not the case yet.

    how do you handle asynchronously loading js files gerard? do you use the html5 async tag close for script elements?
    how do you implement that, if so? since elgg handles the js files when they are cached by elgg.

  • Javascript in simple_cache can be done like this in start.php

            //Register js in cache
            elgg_register_simplecache_view('js/plugin/plugin_uri');
            $url = elgg_get_simplecache_url('js', plugin/plugin_uri');
            elgg_register_js(plugin_uri', $url);

    Asynch loading can be done a number of different ways

    1) In code

    // Load AddToAny script asynchronously
    (function(){
        var a = document.createElement('script');
        a.type = 'text/javascript';
        a.async = true;
        a.src = 'http://yourdomain/page.js';
     };

    2) Use ELGG  (basically asynch since it can be loaded in the footer, if it is not required earlier )

    elgg_register_js(plugin_uri, $url, 'footer');

    3) Google pagespeed Does it automatically, if possible.

    Using ELGG cache for javascript is my most preferrred. You need to make sure that in the view elgg_load_js("plugin_uri)  is loaded at the latest possible time. Also still need to minify the code for best result.

Performance and Scalability

Performance and Scalability

If you've got a need for speed, this group is for you.