Skip to main content

How to exclude the OptiMonk script from cache plugins in WordPress?

Updated over 2 months ago

Why Do We Use Cache Plugins?

WordPress cache plugins are tools that help speed up your website by caching (or storing) some of its content. This means that when someone visits your website, the plugin will serve them a cached version of your pages instead of generating the page from scratch every time. This reduces the overall load on your server and makes your website load faster for visitors.

There are many benefits to using WordPress cache plugins, including:

  1. Faster website loading times: By caching your website's content, visitors can access your content more quickly, which can lead to a better user experience and higher engagement.

  2. Improved website performance: Caching can reduce the overall load on your server, which can help improve website performance, particularly during high-traffic periods.

  3. Better search engine rankings: Google and other search engines give preference to websites that load faster and offer a better user experience. By using WordPress cache plugins, you can help improve your website's search engine rankings.

Overall, WordPress cache plugins are essential tools for any website owner looking to improve website speed and performance. By reducing the load on your server and serving cached content to visitors, you can create a faster and more engaging website experience for your audience.

Why Do These Plugins Cause Issues with OptiMonk?

Due to how OptiMonk works, it needs to be served directly from the OptiMonk servers without any modification to the way the script is added or loaded on your WordPress site.

Will ignoring OptiMonk on my Cache Plugin affect the speed of my WordPress website?

The OptiMonk development team has worked hard to ensure that the OptiMonk script is loaded in an optimized manner without disrupting the loading speeds of assets from your website. OptiMonk utilizes the async tag on the script, which is used to load OptiMonk on your WordPress website. The following is an example of the script that is loaded on your website.

<script type="text/javascript" src="https://onsite.optimonk.com/script.js?account=150394" async </script>

The 'async' tag is an HTML attribute used when loading scripts that allow the browser to continue rendering the page while the script is downloaded in the background. This helps to prevent the script from blocking the page load and can improve page speed and performance. However, it's important to note that using the 'async' tag can cause issues with code that depends on the loaded script, hence why issues arise when your WordPress Plugin caches the OptiMonk script.

How Do I Ignore OptiMonk on my Cache Plugin?

You will need to make sure that the following scripts are added to the ignore list for defer JS, minify JS, and inline JS:

onsite.optimonk.com
front.optimonk.com

If you have any issues configuring your cache plugin on your WordPress site just let us know, and we will be happy to help!

Individual Plugin List / Step by Step


Autoptimize

When the customer is using Autoptimize, we need to add this to the list of scripts that should not be cached.

Open Autoptimize, and under the JavaScript Options settings, we need to add

https://onsite.optimonk.com, https://front.optimonk.com

to the Exclude Scripts from Autoptimize. We also need to tell Autoptimize to load the OptiMonk script async. Go to the Extra tab on the Autoptimize Settings page, and add https://onsite.optimonk.com/script.js to the Async Javascript-files (advanced users)

Autoptimize has a basic toolbar at the top of the page where you can easily delete the cache. Click on Autoptimize and click on Clear CSS/JS Cache.

Test your website, and the OptiMonk campaign should now appear 🙂


Comet Cache

Cache files created by Comet Cache can be deleted by clicking on Comet Cache in the left side menu of the WordPress Dashboard

To delete the cache, you will need to click on the Clear button with a small brush icon found at the top right of the page.

Once this has been completed, the OptiMonk app should start appearing as it should do :)


Litespeed Cache

Litespeed cache is generally found in the toolbar on the WordPress dashboard. To delete the cache from Litespeed, you will need to click on the Litespeed icon and click on “Purge All.” Please note that if you are using Litespeed enterprise then this may take a few moments to clear the CDN cache data.

Once the cache has been purged, OptiMonk should appear on your website :)


Nginx Helper

Nginx cache is a bit different from the standard Apache cache that most web hosts provide to their customers. This is due to how Nginx utilizes FastCGI or redis-cache, and due to this, the Nginx cache would normally need to be done on the server; however, the Nginx Helper plugin allows you to delete the cache from within WordPress.

Depending on the setting,s you can normally delete the cache by clicking on “Purge cache” in the top toolbar

However, there may be some cases where the “enable Purge” settings have been disabled, so this will not show the Purge Cache button in the top bar. In order to delete the Nginx cache, if you cannot see this button in the toolbar, you will need to click on Settings > Nginx Helper from the dashboard side menu

On the Nginx Helper plugin page, you will be able to purge the entire cache. Once this has been done, the OptiMonk campaigns should start working on your website :)


WP Rocket!

You will need to add the OptiMonk URL to the Remove from JavaScript Deferred List as well as the Minify JavaScript Files.

The following screenshot is of the Defer List - WP Rocket Support Document - https://docs.wp-rocket.me/article/976-exclude-files-from-defer-js

https://onsite.optimonk.com
https://front.optimonk.com

The following screenshot is of the Minify List - WP Rock Support Document - https://docs.wp-rocket.me/article/915-find-the-right-js-files-to-exclude-from-minification

onsite.optimonk.com
front.optimonk.com

Once these have been added and saved, you will need to clear and preload the cache


Is the plugin you used not listed?

If the WordPress cache plugin you used is not listed here, then please do let us know, and we will add the steps for the unlisted plugins here! That's it! :) If you have any further questions or need any help, just let us know on our live chat or email at [email protected], and we would be happy to assist you :)

Did this answer your question?