Skip to main content

Caching and security plugins

Better Messages works with caching plugins, CDNs and security plugins. When one of them is set too strictly, the messenger stays blank after an update, a button does nothing, or requests are refused. This page says how to recognize each case and what to change.

After an update the messenger is blank or a part is missing#

The page still loads the scripts and styles of the version before. The plugin gives each file a version number in its address, so browsers take the new one, but a cache can keep serving the old file.

  1. Purge the page cache of your caching plugin.
  2. Purge the CDN. Some CDNs ignore the version number at the end of a file address unless they are told to take it into account: on Bunny CDN it is the pull zone setting that makes the query string part of the cache key. With it off, the CDN serves the old file under the new address until it is purged.
  3. Reload without the browser cache: Ctrl+Shift+R, or Cmd+Shift+R on a Mac.

If the messenger works in a private window and not in the normal one, the browser cache is the cause.

A button does nothing, or the messenger never loads#

JavaScript optimization is the most common cause. The scripts of Better Messages are already minified, and a plugin that minifies them again, combines them with other files, or delays them can break one.

In your optimization plugin, exclude the files of Better Messages from:

  • JavaScript minification
  • combining or merging JavaScript files
  • delaying or deferring JavaScript, and loading scripts only after the first interaction

The exclusion is usually a part of the file address. better-messages matches every file of the plugin, of the free and the WebSocket version alike.

To find out fast whether optimization is the cause, switch the JavaScript options of the plugin off, purge its cache, and reload. LiteSpeed Cache, WP Rocket, Autoptimize, W3 Total Cache, WP-Optimize, SiteGround Optimizer and the script features of Cloudflare all have such options.

The same goes for translations that fall back to English after an update: the words of the messenger are loaded by a script, and a combined or cached copy of it carries the old words. See Translations.

Pages cached for logged-in members#

A page cache must not serve the same copy of a page to different logged-in members. The page carries the member it was made for, so a cached copy shows the wrong unread count, or the requests of the messenger are refused with a message such as "Authorization failed".

  • Switch off the caching of pages for logged-in users, or exclude the page of the messenger from the cache.
  • Exclude the REST API of the plugin from any REST cache: addresses that start with /wp-json/better-messages/.

When the REST API is blocked#

Better Messages sends and loads everything through the WordPress REST API, at addresses that start with /wp-json/better-messages/v1/. Test it by opening this address, with your own domain:

https://example.com/wp-json/better-messages/v1/ping

It must show pong. On a site whose permalinks are set to Plain, the address is https://example.com/?rest_route=/better-messages/v1/ping. When it does not show pong, find what stands in the way:

What you seeUsual causeWhat to do
403 ForbiddenA security plugin, or the firewall (WAF) of the host or the CDN.Allow addresses that start with /wp-json/better-messages/. The log of the firewall names the rule that blocked the request.
A message that the REST API is restricted, such as "Only verified users have access to the REST API"A plugin or snippet that closes the REST API to visitors.Allow the namespace better-messages/v1, or switch that option off. Guests and the mobile app need it without a WordPress login cookie.
404 Not FoundThe rewrite rules of WordPress are missing, or a redirect rule catches the request.Open Settings → Permalinks and press Save Changes, which writes the rules again. On Apache, check that .htaccess has the WordPress rules.
A captcha or a challenge pageThe bot protection of a CDN or firewall.Leave /wp-json/better-messages/ out of the challenge. A script cannot solve it.
Members are blocked one by one, each for a whileA firewall that counts requests, such as Imunify360, and blocks an address that makes many.Ask the host to allow the REST API of the plugin. On the free version, a longer refresh interval under Settings → General → Realtime Update Mechanism makes fewer requests.

A request that Better Messages itself refuses says why, in words and in the language of your site. A bare number, such as 404 alone, comes from something in front of it.

Uploads are refused with 403#

A firewall can refuse an upload because of its file name: long names, names in a non-Latin alphabet, or unusual characters. Turn on Settings → Attachments → Randomize Filenames, which gives every file a plain name before it is sent. If uploads still fail, see Files do not upload.

Animated GIFs stop moving#

An image optimization plugin, or the image optimization of a CDN, rewrote the file and kept only its first frame. Leave the uploads of Better Messages out of that optimization, or switch it off for GIF files. In Better Messages itself, Settings → Attachments → Strip Metadata needs the Video Engine to keep animated images moving.

The site cannot reach the cloud#

The WebSocket version also connects from your server to the cloud, for example to start a group call. A host that blocks outgoing connections makes those requests fail, with a message such as "cURL error 7" in the error log. This is not something a CDN in front of the site controls, as it handles only what comes in. Ask the host to allow outgoing HTTPS connections from the site.

The other way round, the cloud sends some results back to your site, such as AI translations. When a firewall blocks those requests, the results still arrive, more slowly, through WP-Cron.

See also#