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.
Tuning the Plugin Settings
You may consider the following option settings to fine-tune the plugin for optimal performance.
- If your website content does not have any embedded videos, or you prefer not to include embedded videos in your Open Graph and Twitter Card meta tags, you can set the “Maximum Number of Videos” to “0”. This will prevent the plugin from searching your content for embedded videos.
- If you want to limit which video services are supported, check / uncheck one or more of the ‘Check for Embedded Media’ options on the Advanced settings page.
- 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).
- If no excerpt 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 Content Filters” option.
- You can increase the “Object Cache Expiry” option from 86400 seconds (the default) to several days / weeks.
- If you don’t use an object / transient cache (like APC, XCache, memcache, etc.) and you have a website with thousands of posts and pages, the creation of transient cache objects may put additional / unwanted load on your database (WordPress saves transient objects to the database by default). You should install an object / transient cache, but 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:
12345define('NGFB_FILE_CACHE_DISABLE', true);define('NGFB_TRANSIENT_CACHE_DISABLE', true);define('NGFB_OBJECT_CACHE_DISABLE', true);
- 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:
If you have not installed an opcode and/or transient object cache, you 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.
- WordPress Caching and Plugins for Performance
- Save Memory with Alternative PHP Cache (APC)
- Memcached vs Disk Cache
Full-Page Caching (Plugins or Front-Ends)
article:author value is not compatible with the Open Graph standard. Depending on the Pinterest ‘Author Name Format’ option (see the NGFB General settings page), NGFB 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 based on the user agent value.
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:
( strpos( $_SERVER['HTTP_USER_AGENT'], 'Pinterest/' ) !== false ? 'Pinterest' : '' )
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:
# defragment mysql tables
0 3 * * * export TERM=vt100; /usr/local/bin/mysqlfragfinder.sh >/var/tmp/mysqlfragfinder.log
And to prevent the script from stopping for a password, add an entry for it in the
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 v22.214.171.124 (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 v126.96.36.199 (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 v188.8.131.52
- 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).