logo top
logo middle
  • +44 1293 403636
  • This e-mail address is being protected from spambots. You need JavaScript enabled to view it.
  • Follow us on Twitter
  • Facebook
  • Google+

Bob Mitchell

Bob Mitchell

Technical Account Manager - wrangler of things, projects and people.

Contact me:

bob dot mitchell at scl dot com

Twitter: @boborama

LinkedIn: bobmitchell

Google+: +boborama

website - comments and caching

I felt like writing a few words about the little hacks necessary to make this website work - partly as documentation and partly in case anyone else ever has any use for it.

The website is run using Joomla! 1.7 under Apache. The clean URLs are courtesy of AceSef (paid-for, with extra modules for some components)

As the performance of the Joomla! installation leaves a lot to be desired we run a distinct proxy/caching layer in front of it, I'd considered Varnish, but right now we're using nginx.

After using the stock nginx available via our yum repository there were a couple of extras that seemed like they would be useful, so we have a built-from-source version 1.0.9 (at the time of writing) with the ngx_cache_purge module from Frickle Labs compiled in (and some unnecessary stuff removed).

This, with a simple configuration of

location ~ /purge(/.*) {
                allow                   // address of apache box;
                deny                    all;
                proxy_cache_purge       my-cache   $1$is_args$args;
}

allows the Joomla! instance to force the nginx cache to purge a specific resource.

One place that needed this applied was the comments system (UjjaComments) - when a new comment is posted the cache for that page should be purged to allow the comment to show up straight away. In mod_udjacomments/mod_udjacomments.php I added the following:

file_get_contents('http://www.scl.com/purge'.$_SERVER["REDIRECT_URL"]);

just before:

$application->redirect($currentUrl, JText::_('MOD_UDJACOMMENTS_COMMENTSAVE_SUCCESS'), 'message');

It's a bit brutal, but seems to work. The result is that comments are, as you'd expect, available immediately (providing that they aren't classified as spam) while the majority of the content most of the time is served directly from Nginx. Using the cache/proxy layer has improved the performance of the site significantly, we were seeing the request for the page itself (never mind the assets on the page) take well over a second and, providing that it hits the cache we're now down to a few milliseconds of server time.

This should have a meaningful positive impact on user experience and while we don't have metrics to support this assertion, the performance of the site is no longer something that I'm ashamed about.

 

 

    Post your comments...

    Upcoming Events

    Contact SCL

    • +44 1293 403636
    • This e-mail address is being protected from spambots. You need JavaScript enabled to view it.
    • Follow us on Twitter
    • Facebook
    • Google+