Press enter to see results or esc to cancel.


Caching plugins can be easily installed and will cache your WordPress posts and pages as static files. These static files are then served to users, reducing the processing load on the server. This can significantly improve performance.

Please keep in mind that just installing a caching plugin does not necessarily make your site faster. Doing a bit of optimization will get you a lot of speed increase without caching plugins. To further combat slowness you may want to re-evaluate the performance of your hosting package. Maybe you’ve outgrown it. In that case, upgrade to a better hosting solution.

Caching on the frontend side (what visitors see) in some cases does speed up page loading but may cause some unwanted behavior. When you are using caching and visitor visits some page, WordPress creates that page, Ad Inserter is called to do the job, the created page is sent to the visitor and it is also saved for quicker serving later. The next time the page is visited, the visitor gets cached (saved) page. Because of this some Ad Inserter server-side functions can not work because Ad Inserter is not called when the page is cached:

  • Ad rotation
  • Server-side device detection
  • Server-side referer check
  • Server-side cookie check
  • GEO targeting (IP address check)
  • Scheduling
  • User check
  • Debugging functions

When you need the functions listed above you have to switch off caching (if possible only on selected pages where needed). However, Ad Inserter also supports some of the functions above even when caching is enabled:

For this to work you need to set Dynamic blocks (tab / tab General) to client-side (code executed in the visitor’s browser). Ad Inserter supports two client-side modes for dynamic blocks: Client-side show and Client-side insert. Both generate Javascript code to run in the browser. Client-side show uses CSS to hide unwanted code while Client-side insert uses Javascript to insert code when needed or enabled. Client-side show is fine with banners as they are all loaded and only shown when needed but some adverts (e.g. AdSense) might not work properly or can’t be used this way and you might violate their Terms of Service – use Client-side insert mode in such case.

It is ESSENTIAL that the caching/opimizing plugin does NOT CHANGE the Javascript code generated by Ad Inserter. If it optimizes or modifies the javascript code on the page, it must ensure its integrity so that the code remains functional and no Javascript errors are reported on the page. Please contact support of your caching plugin if you experience issues when it is enabled.

Client-side show is fine with banners as they are all loaded and only displayed when needed but some adverts (e.g. AdSense) can’t be used this way – use Client-side insert mode in such case.

Some ad codes use old JavaScript method document.write which can’t be used asynchronously (after the page is loaded and created). Client-side insert mode will not work with such ad codes.

If you are using W3 Total Cache for caching then you can still use server-side ad rotation, referer, cookie, IP address and country check even when the pages are cached as Ad Inserter supports special features of this caching plugin. Check section W3 Total Cache for details.

If you are using caching, the inserted code may not appear immediately on the page. Make sure you disable caching when you are testing or debugging. Some caching plugins like WP Super Cache have an option to disable caching for known users.

There is also an option to disable caching on specific pages (button Misc / tab Insertion). This option will prevent caching of pages where code blocks with this option enabled are inserted. This option works with WP Super Cache, W3 Total Cache and WP Rocket caching plugins. After you enable this option make sure you flush the cache.

Few additional notes when using client-side IP address or country detection:

  • Page with dynamic blocks needs to access /wp-admin/admin-ajax.php page on your web server to get IP address and country. Make sure it is accessible and not password protected.
  • Since the code block (when allowed) is displayed or inserted only when the page is loaded and country checked, you may notice a very short delay (few 100 ms) before the code (or ad) is displayed.
  • When Ad Inserter Pro (using client-side detection of IP address and/or country) makes the block visible, the content below shifts downwards.
  • Client-side show method for IP address and country detection uses div element to wrap the code(s) even when you use No wrapping style.

WP Rocket

WP rocket caching plugin can delay execution of JavaScript code. To prevent delaying Ad Inserter code add the lines below to the Excluded JavaScript Files field:


W3 Total Cache

If you are using W3 Total Cache for caching then you can still use server-side ad rotation, referer, cookie, IP address and country check even when the pages are cached as Ad Inserter supports special features of this caching plugin. To enable this mode go to Ad Inserter plugin settings tab / tab General and set Dynamic blocks to Server-side with W3 Total Cache and configure W3 Total Cache for dynamic content.

When Dynamic blocks is set to Server-side with W3 Total Cache and you are using ad rotation, referer, cookie, IP address or country check, Ad Inserter inserts short PHP code with special tags in place of code block. When W3 Total Cache plugin loads cached page it executes this code before it serves the pages. So the page is still served from the cache but the Ad Inserter blocks are dynamically created just before the page is served. Therefore, pages are served from the cache and the Ad Inserter code is still generated on the server-side.

Configure W3 Total Cache

How to fully set up W3 Total Cache is beyond the scope of this page. Check the W3 Total Cache manuals or contact its developer for help with that if you need it. To work with Ad Inserter you need to do the following:

  • In General Settings set Page Cache Method to Disk: Basic
  • In Page Cache under Advanced enable Late Initialization
  • If you use Minify option then add mfunc to the Ignored comment stems field

You need to flush the cache after making these changes.

Please note also the following:

  • Mixing static cached and dynamic content is a tricky thing to do and often causes all kinds of issues. Ad Inserter follows the guidelines from W3 Total Cache on this. If it doesn’t work it’s very likely you didn’t configure W3 Total Cache correctly. Alternatively, you can decide to use client-side option for dynamic blocks – your adverts will show up just fine and rotation and GEO targeting will still work.
  • In order to use dynamic content with W3 Total Cache, W3TC_DYNAMIC_SECURITY PHP constant needs to be defined. Usually it is located in the wp-confing.php file. This is a security string used when generating PHP code for dynamic content. If this constant is not defined, Ad Inserter will define and use it.
  • Do not use debugging functions when caching is activated.
  • When you make changes in settings of the W3 Total Cache purge all caches before you check page.
  • If you deactivate W3 Total Cache plugin, Ad Inserter will use Server-side instead of Server-side with W3 Total Cache setting for Dynamic blocks.
  • After you activate W3 Total Cache plugin go to W3 Total Cache General Settings and click on Save all settings.