Performance Tuning

The code for NextGEN Facebook (NGFB) is highly optimized — the plugin will not load or execute code it does not have to — and unlike most plugins, NGFB makes full use of all available caching techniques:

  • Non-persistent (WP Object Cache) object caching for rendered (filtered) Post and Page content.
  • Persitent (Transient API) object caching for the Open Graph and Twitter Card meta tags, social buttons widget, shortcodes and content social buttons.
  • Using an optional file / disk based cache for javascript and images from social websites (Pro version).

Tuning the Plugin Settings

You may consider the following option settings to fine-tune the plugin for optimal performance.

  1. If you’ve saved a few posts and pages without any duplicate meta tag warnings, you can disable the “Check for Duplicate Meta Tags” option in the NGFB > Advanced > Theme Integration settings. This will prevent NGFB from fetching the front-end webpage when editing posts and pages.
  2. If your website content does not use any embedded videos, or if you prefer not to include embedded videos in your Open Graph and Twitter Card meta tags, set the “Maximum Number of Videos” to “0” in the NGFB > General > Videos settings. This will prevent the plugin from searching your content for embedded videos.
  3. If you want to limit which video service APIs are supported, enable/disable one or more of the “Check for Embedded Media” options in the NGFB > Advanced > Content and Filters settings.
  4. If you generally have a featured image for your posts and pages, you may set the “Maximum Number of Images” to “1” (the default value). This will prevent the plugin from searching your content for additional images (the featured image counts as “1” and the plugin will stop there).
  5. If no excerpt / summary text is available, the content text will be used to create the Open Graph description value. If your content does not rely on shortcodes or plugins to render its text, you may uncheck the “Apply WordPress Content Filters” option in the NGFB > Advanced > Content and Filters settings.
  6. You can increase the “Object Cache Expiry” option in the NGFB > Advanced > File and Object Cache settings from 86400 seconds (the default) to several days / weeks. NGFB removes outdated cache objects when posts / pages are updated, so increasing the default values should not create any issues.
  7. If you don’t use an object / transient cache (like APC, XCache, memcache, etc.) and have a website with tens of thousands of posts and pages, the creation of transient cache objects will put additional / unwanted load on your database (by default, WordPress saves transient objects to the database). Using the database for transient objects shouldn’t be a problem unless you have a preexisting database performance issue. Aside from making sure your database is running well, you should also install an object / transient cache. If that’s not possible, you may turn off one or more of NGFB’s caching features by adding the following constant(s) to your wp-config.php file:

    Start by disabling only the transient cache — the file and object caches should not affect database performance.

  8. If you don’t use the NGFB sharing buttons, you can disable all sharing button features by adding the following constant to your wp-config.php:

    Alternatively, you may want to update from NGFB to WPSSO. WPSSO is a fork / child of NGFB — they have the same author, the same core features and code-base, but WPSSO is distributed without the sharing buttons and their related features (making WPSSO about 25% smaller than NGFB). Additional extension plugins are also available for WPSSO, including:

Optimize WordPress

If you have not installed an opcode and/or transient object cache, you really should. There are many great articles on optimizing WordPress, which cover the subject of opcode and object caching. Here are a few that I’ve written (though they may be a little too technical for some). Please take the time to research opcode and transient object caching solutions – they will make a big difference to your website’s performance and maximum concurrent user capacity.

Full-Page Caching (Plugins or Front-Ends)

Pinterest’s expected article:author value is not compatible with the Open Graph standard. Depending on the Pinterest “Author Name Format” option in the SSO > General > Pinterest settings, WPSSO may create different Open Graph meta tags for the Pinterest crawler. If you use a full-page caching plugin (for example), you should disable caching for the Pinterest crawler or save a different cached version. For example, you could disable caching for the following user agent:

If your caching plugin supports PHP expressions to generate a cache ID, you could use:

Defragment the Database

The database tables in MySQL can become fragmented as entries are added/removed/updated, especially the options table which holds the transient cache entries. You should defragment you database tables at least daily. I use Phil Dufault’s mysqlfragfinder.sh script for my own databases.

Here is an example crontab entry:

And to prevent the script from stopping for a password, add an entry for it in the ~/.my.cnf file:

Performance Tests

And lastly, you should perform at least two types of performance tests on your website — A PHP code execution speed test using P3 (Plugin Performance Profiler), and a browser rendering speed test from the WebPageTest website (or equivalent). The first test will show you the speed penalty incurred by each active plugin. You can expect excellent results from NGFB. As an example, here are the PHP code execution speed results from P3 (Plugin Performance Profiler), using WP Test Data and the default settings of a few popular plugins:

  • 0.0105 secs – WordPress Social Sharing Optimization (WPSSO) v2.5.2
  • 0.0117 secs – All in One SEO Pack v2.1.4
  • 0.0130 secs – MarketPress – WordPress eCommerce v2.9.2.1 (No Products)
  • 0.0164 secs – NextGEN Facebook (NGFB) v7.5.2
  • 0.0189 secs – Contact Form 7 v3.7.2
  • 0.0322 secs – WP e-Commerce v3.8.13.3 (No Products)
  • 0.0393 secs – bbPress v2.5.3 (No Forums or Topics)
  • 0.0405 secs – WooCommerce v2.1.5 (No Products)
  • 0.0572 secs – SEO Ultimate v7.6.2
  • 0.0579 secs – Facebook v1.5.5
  • 0.0656 secs – BuddyPress v1.9.2 (No Activities)
  • 0.1051 secs – WordPress SEO by Yoast v1.5.3.3
  • 0.1980 secs – JetPack by WordPress.com v2.9.2

Tests executed on a VPS with SSDs and 6GB ram, APC opcode/object cache, WordPress v3.8.1, P3 v1.4.1 configured with opcode optimization enabled (improves accuracy).

The second test (browser rending speed) from the WebPageTest website, is a classic test to show which elements take longer to load, etc. NGFB’s execution time (see P3 results above) should not contribute in any significant way to these results, although if you’ve enabled some social sharing buttons, their JavaScript file transfer and execution will impact page load times to various degrees.

Leave a Reply

Your email address will not be published. Required fields are marked *