FastComments.com

Add Live Commenting to WordPress and Drupal Sites on Pantheon

This guide covers installing FastComments on a WordPress or Drupal site hosted on Pantheon, and the Pantheon features that affect the integration: the Dev, Test, and Live workflow, Integrated Composer, the Global CDN, and Pantheon Cron.

Pantheon hosts WordPress and Drupal sites. Both use their core comment systems by default, which store comments in each environment's database. The FastComments WordPress plugin and Drupal module replace the core comment system with the FastComments widget. Their setup, moderation, and SSO options are described in the WordPress guide and the Drupal guide. This guide does not repeat them.

This tutorial requires a FastComments account. You can create an account here.

Install the Plugin Internal Link

On Pantheon, code can only be added or changed on the Dev environment (and Multidev environments). Test and Live receive code through deploys, and their code is read-only. Installing a plugin from the WordPress dashboard works only on Dev in SFTP connection mode. If WordPress asks for FTP credentials, the environment or the connection mode is wrong.

Install on Dev

  1. In the Pantheon Site Dashboard, open the Dev tab, select Code, and set the connection mode to SFTP.
  2. Click Site Admin to open the WordPress dashboard of Dev.
  3. Go to Plugins > Add New, search for FastComments, and click Install Now.
  4. Return to the Site Dashboard, review the pending changes, enter a commit message, and click Commit.

The plugin is also available from wordpress.org/plugins/fastcomments. Sites based on Pantheon's wordpress-composer-managed upstream add plugins with Composer instead, from the WordPress.org mirror configured in the site's composer.json (WPackagist or WP Packages).

Deploy to Test and Live

  1. Open the Test tab, select Deploys, and click Deploy Code from Development to Test Environment.
  2. Open the Live tab, select Deploys, and click Deploy Code from Test to Live Environment.

Plugin activation is stored in the database, and each environment has its own database. Activate the plugin on each environment where you want FastComments, from Plugins in that environment's WordPress dashboard.

The same steps with Terminus:

Install and Deploy with Terminus
Copy Copy
1
2terminus connection:set <site>.dev sftp
3terminus wp <site>.dev -- plugin install fastcomments
4terminus env:commit <site>.dev --message="Install FastComments"
5terminus env:deploy <site>.test
6terminus env:deploy <site>.live
7terminus wp <site>.live -- plugin activate fastcomments
8

Run the Setup on Live

Click FastComments in the WordPress left navigation of the Live site and follow the setup steps. The Live database holds the site's current comments, so run the setup there to upload them to FastComments. The setup is described in the WordPress guide.

Network Requirements

All requests made by the plugin are outbound HTTPS requests from Pantheon to fastcomments.com, or to eu.fastcomments.com for EU accounts. The plugin's REST routes under /wp-json/fastcomments/v1/api/ are used by the plugin's admin pages and require an administrator.

Cron and Comment Sync Internal Link

The plugin copies comments from FastComments back into the WordPress database with a WP-Cron event, fastcomments_cron_hook. The copy is kept for backups and for plugins that read WordPress comments. Comments are shown to visitors from FastComments, so the sync schedule does not affect what visitors see.

Sync Interval

Choose how often the sync runs with the Sync Interval setting on the plugin's Advanced Settings page:

  • Every 24 hours (default)
  • Every hour
  • Every 15 minutes
  • Every 5 minutes

How Pantheon Runs WP-Cron

Pantheon's WordPress upstream disables WP-Cron on page requests. Pantheon Cron runs wp cron event run --due-now once an hour on each environment instead. It does not run on environments that are idle and have spun down, and a cron run can take at most 180 seconds (Pantheon Docs: Cron for WordPress).

The Every 24 hours and Every hour intervals run on schedule with Pantheon Cron. The Every 15 minutes and Every 5 minutes intervals run at most once an hour, unless an external service calls the site's cron. To run cron more often, Pantheon's documentation describes disabling WP-Cron in wp-config.php above the require_once for wp-config-pantheon.php, and calling https://example.com/wp-cron.php?doing_wp_cron from an external cron service, for example every 15 minutes.

On WordPress Multisite, Pantheon Cron is disabled by default and standard WP-Cron runs on page requests.

Initial Comment Upload

During setup, the plugin uploads existing WordPress comments to FastComments while the setup page is open. If the setup page is closed before the upload finishes, the upload continues through one-off WP-Cron events, which on Pantheon run with Pantheon Cron once an hour. Keep the setup page open until the upload completes.

Running the Sync Manually

The sync can be started at any time from the plugin dashboard with Manually Sync, as described in the WordPress guide. With Terminus, run the due WP-Cron events of an environment:

Run Due Cron Events with Terminus
Copy Copy
1
2terminus wp <site>.live -- cron event run --due-now
3

Page Cache Internal Link

Pantheon's Global CDN caches full pages. FastComments works with it without cache rules or exclusions, on both WordPress and Drupal.

Anonymous Visitors

The WordPress plugin and the Drupal module output a container element and a script that loads from cdn.fastcomments.com and calls FastCommentsUI. Comments are loaded in the visitor's browser, not rendered into the HTML. The widget configuration in the page is the same for every anonymous visitor of a page, so cached pages are correct for all anonymous visitors, and new comments appear without clearing the cache.

The Drupal module also adds the user cache context and the config:fastcomments.settings cache tag to its output, so Drupal's own render cache varies the widget per user and invalidates it when the module settings are saved.

Logged-In Users and SSO

With SSO enabled, the page HTML contains the SSO payload of the logged-in user. The Global CDN does not cache requests that carry a session cookie. Pantheon's list of cache-busting cookie patterns includes (Pantheon Docs: Working with Cookies):

  • S+ESS[a-z0-9]+, which matches Drupal's SESS and SSESS session cookies.
  • wordpress[A-Za-z0-9_]*, which matches WordPress's wordpress_logged_in_ cookie.

Requests from logged-in users bypass the cache, so an SSO payload is never stored in a cached page or served to another visitor. The cookie list is set by Pantheon for the whole platform and cannot be changed per site.

Clearing the Cache

Clear the cache of an environment after enabling, configuring, or removing FastComments on it:

  • In the Site Dashboard, open the environment and click Clear Caches. This clears the environment's caches and the Global CDN.
  • With Terminus:
Clear the Live Cache
Copy Copy
1
2terminus env:clear-cache <site>.live
3

When deploying to Live from the dashboard, the Clear Caches option clears the cache as part of the deploy. Widget customizations made in the FastComments dashboard do not require clearing the cache, because the widget loads them in the browser.