Store locator broken after an update?
Clear your CDN and page cache

If the store locator stopped working right after you updated WP Store Locator, a CDN or cache is most likely still serving the old plugin scripts. Purging the CDN, your page cache and any script optimizer cache fixes it, usually within minutes. This page shows how to confirm it, how to clear each cache, and how to stop it from happening on the next update.

Symptoms

The problems start right after a plugin update, often only for some visitors or only when you are logged in:

  • A search returns no results, or the map stays blank or grey.
  • Settings you changed seem to have no effect, for example a country restriction or the autocomplete version.
  • The browser console shows errors from WP Store Locator files, such as Uncaught TypeError: Cannot read properties of undefined (reading '0') in wpsl-gmaps-js.min.js, or e[s] is not a function in wpsl.min.js.
  • From version 3.1.1, the browser console shows a warning that starts with “WP Store Locator: the installed plugin is build …”. Administrators also see a notice above the store locator that says the browser received scripts from a different plugin version.

Why it happens

The page and its settings come from the new version, but the scripts come from the old one, and the two don’t work together. WordPress adds the plugin version to every script URL, for example wpsl.min.js?ver=3.1.1, so a new version gets a new URL and browsers fetch the new file. That only works if every cache in between treats the version as part of the URL.

Three kinds of cache can break this:

  • A CDN that ignores query strings. Amazon CloudFront’s default cache policy does this: ?ver=3.1.0 and ?ver=3.1.1 are the same file to it, so it keeps serving the old copy until its cache expires, which can take days or longer.
  • A full page cache. A cached page can still reference the old settings and templates while the new scripts load, or the other way around.
  • A script optimizer that combines or minifies scripts into its own files, such as WP Rocket, Autoptimize, LiteSpeed Cache or a host’s optimization layer, and keeps those files after the update.

Check whether your CDN ignores the version

From version 3.1.1, WP Store Locator checks this for you. Open Store Locator > Home: if your CDN serves outdated scripts, or ignores the version in script URLs, it shows an alert in the Alerts section and in the admin bar. To run the check again after clearing a cache, go to Store Locator > Settings > Tools and choose Check now next to Outdated cached files.

For developers

Request the main script with a version that doesn’t exist, and look at the cache headers. Replace example.com with your domain:

curl -sI "https://example.com/wp-content/plugins/wp-store-locator/assets/dist/frontend/js/wpsl.min.js?ver=test123" | grep -iE "^(x-cache|cf-cache-status|age|last-modified):"

Use a new value each time you run it, such as test124, because the second request for the same value can come from the cache even when the CDN is set up correctly.

A version nobody has requested before should never come from the cache. If you see one of these, your CDN ignores the version:

Header Means the CDN served a cached copy
x-cache: Hit from cloudfront Amazon CloudFront
cf-cache-status: HIT Cloudflare
x-cache: HIT or x-proxy-cache: HIT Other CDNs and hosting caches
age: 580108 (any large number) The copy is that many seconds old

No terminal? Open the store locator page, open the browser’s developer tools (F12), and look at wpsl.min.js on the Network tab. The response headers show the same values.

Fix it now: clear the caches

Clear the caches from the inside out, so an outer cache can’t store the old files again:

  1. Script optimizer. Clear the cache of the plugin that combines or minifies scripts, for example Autoptimize’s “Delete Cache” in the admin bar.
  2. Page cache. Purge everything in your caching plugin, for example “Clear and preload cache” in WP Rocket, “Purge All” in LiteSpeed Cache, or “Purge All Caches” in W3 Total Cache. If your host has its own cache, clear it in the hosting dashboard.
  3. CDN.
    • Amazon CloudFront: open the distribution, go to Invalidations, choose Create invalidation, and enter /*. Or run aws cloudfront create-invalidation --distribution-id YOUR_ID --paths "/*".
    • Cloudflare: go to Caching, then Configuration, and choose Purge Everything.
    • Other CDNs: use the “purge all” or “invalidate” option in its dashboard.
  4. Your browser. Reload the store locator page with Ctrl+Shift+R (Cmd+Shift+R on a Mac).

The store locator should now work, and the warning and notice from version 3.1.1 are gone. The check above keeps reporting cache hits until you change the CDN’s cache key, see the next section.

Prevent it on the next update

Make the CDN treat the query string as part of the URL. This also protects every other plugin and theme on the site, which all rely on ?ver= the same way.

Amazon CloudFront

  1. Open the distribution and go to Behaviors.
  2. Select the behavior that serves /wp-content/*, or the default behavior if there is no separate one, and choose Edit.
  3. Under Cache key and origin requests, pick a cache policy that includes query strings. The managed policy UseOriginCacheControlHeaders-QueryStrings does, CachingOptimized doesn’t. Or create your own policy with Query strings set to All, or to Include specified query strings with ver.
  4. Save, then invalidate /* once.

Cloudflare includes the query string by default. Check that Caching Level, under Caching and then Configuration, is set to Standard and not to Ignore query string.

Page cache and script optimizers: some clear themselves when a plugin is updated, for example LiteSpeed Cache with Purge All On Upgrade turned on. If yours doesn’t, clear it after each update, or turn on its option to purge on plugin updates.

Still broken?

Contact support and include:

  • The URL of the store locator page.
  • The output of the curl check above, or a screenshot of the alert on the Home page.
  • Everything WP Store Locator writes to the browser console, including the build warning if there is one.
  • The names of your caching, optimization and CDN services.