Use Caching and Optimisation Plugins With ExactFind

ExactFind works with caching and optimisation plugins, CDNs and Cloudflare. A few settings in those tools can break it, though: the search box looks wrong, doesn't respond, or shows an old version after an update. This article covers what to leave alone.

When ExactFind's files load

ExactFind loads its CSS and JavaScript only on pages that show a search box: the block, the [exactfind] shortcode or the floating widget. Other pages don't load them, so there's nothing to optimise there.

HandleTypeFileLoads with
exactfindCSSexactfind/assets/exactfind.cssAll
exactfind-knowledgeCSSexactfind-knowledge/assets/knowledge.cssKnowledge
exactfind-linksJavaScriptexactfind/assets/links.jsAll
exactfindJavaScriptexactfind/assets/exactfind.js, or exactfind-knowledge/assets/knowledge.js with KnowledgeAll
exactfind-turnstileJavaScriptCloudflare's Turnstile scriptBot protection on
exactfind-challengeJavaScriptexactfind/assets/challenge.jsBot protection on

The files are in /wp-content/plugins/. Most optimisation plugins let you exclude a file by its handle, its file name or part of its path, such as /plugins/exactfind.

Don't remove, reorder or delay the files

Exclude ExactFind's files from these optimisation features:

  • Removing or dequeuing scripts and styles on chosen pages. Without them, the search box shows but doesn't answer.
  • Combining files out of order. exactfind needs exactfind-links to load first. Combining CSS and JavaScript is fine if the order is kept.
  • Delaying JavaScript until the visitor interacts with the page. The search box won't respond to the first question, or the Turnstile check won't load.
  • Removing unused CSS. The chat conversation, suggested questions and feedback buttons are built by JavaScript after the page loads. A tool that scans the page for used classes won't find them and strips their styles. Add exactfind to the tool's list of classes to keep, or exclude ExactFind's CSS files.

Minifying the files is fine.

Don't cache the answer routes

Page caching is fine for pages with a search box. The answers themselves must never be cached, because each one is made for that question and streams back word by word. Exclude these from page caching, edge caching at your CDN or Cloudflare, and any compression or optimisation rule:

/wp-json/exactfind/
/wp-json/exactfind-knowledge/

Most caching plugins don't cache the REST API by default. Check anyway if you've added rules at your CDN. A cached or buffered answer is covered in Answers Not Streaming? Fix Delayed AI Replies.

After you update ExactFind

  1. Clear your caching plugin's page cache.
  2. Clear the CSS and JavaScript cache in any optimisation plugin.
  3. Purge your CDN or Cloudflare cache.
  4. Check a page with a search box in a private window.

ExactFind adds its version number to each file link, such as exactfind.css?ver=0.2.1. A new version makes browsers and CDNs fetch the new file. Some themes and optimisation plugins remove these version numbers, so old files can stay cached after an update. One of our own sites does this, so after each update we purge ExactFind's files in Cloudflare by their full URLs. If your site removes version numbers, do the same.

Logged-in users

With Knowledge's Logged-in users only setting, the page carries a security token for the signed-in visitor. Caching plugins normally don't cache pages for logged-in users, so this works without changes. If yours does, turn that off for pages with a search box.

Still broken?

Was this helpful?

Still stuck?

Tell us what you were trying to do and what happened. We reply by email.