The cache-busting in Advanced Ads Pro is needed on cached websites that serve ads with dynamic features like:

  • rotate ads in the same group
  • show different ads to different users (e.g. based on browser width, device or referrer)
  • ads with PHP code

The cache-busting works with caching that is either provided by a caching plugin (e.g. WP Rocket, WP Super Cache or W3 Total Cache) and with cache set up by your hosting provider or through Cloudflare.

Cache-busting can be enabled for each placements individually.

Overview

Passive, ajax or no cache-busting?

There are two cache-busting methods, passive and ajax.

Passive cache-busting loads all possible ads into the pages html code and then uses JavaScript to deliver the correct ad. This is super fast, but takes more space and doesn’t work with all conditions.

Ajax cache-busting uses an ajax call to the WordPress dashboard to load the correct ad. This takes a bit more performance, but works with all dynamic features.

While the best choice in many cases is to keep the cache-busting setting of a placement on auto and use passive cache-busting as the default method, knowing about the advantages and disadvantages of each method might help you to make a better individual choice.

procontra
no cache-bustingfast, no script conflictsad rotations, PHP output and visitor conditions are cached and might not work properly
ajax cache-bustingmost flexible and reliable cache-busting method

little extra output in the frontend

conflicts with ad codes that don’t support ajax requests

extra call to WordPress dashboard

passive cache-bustingloads ads as fast as without cache-busting

performs check in the browser, not on your server

more html and javascript code on your page

not possible with all visitor conditions (see below)

conflicts with complex ad codes

When to disable cache-busting

Cache-busting either needs more performance (ajax cache-busting) or source code (passive cache-busting). Therefore, you should consider to not use it in some cases, e.g.

  • you have so many different pages, that despite caching, the ads in a rotation are delivered equally
  • your PHP output is static, e.g. echo "hello";
  • you only use visitor conditions for visitors that don’t use the cache (e.g. admins)

Features that don’t work with passive cache-busting

Since passive cache-busting only uses JavaScript to deliver ads, some ad features can’t be used with it.

  • user capability and logged-in visitor condition
  • the geo location condition
  • using PHP with dynamic output
  • using the ad-group ad type

You can set a fallback method (ajax cache-busting or no cache-busting) in the main options.

Auto cache-busting

The auto option for cache-busting of a placement first checks if cache-busting is needed at all. It will switch off to save performance when all of these conditions are met:

  • only one ad is displayed (single ad selected or an ad group with only one ad inside)
  • no visitor condition is selected
  • no PHP is used
  • no ad group ad type used

The next method (passive or ajax) will be selected based on the main settings (see below).

Usage

Download, install and enable the Advanced Ads Pro add-on.

General options

Activate the cache-busting module in Advanced Ads > Settings > Pro.activating cache busting module

Save the main setting and select the preferred order of cache-busting methods used when the setting is set to auto.

Please note, that Advanced Ads always first checks if cache-busting is needed at all (see above).

cache busting options

In order to not cache an ad or an ad group, you have to deliver it through a placement. The default option is auto.

cache-busting placement setting

Refresh the website cache.

Here are some ideas to check, whether or not cache-busting is working:

  • Create an ad group with two or more equally weighted and rotating ads and see if you see different ads when reloading the page multiple times.
  • Create an ad with a visitor conditions set to display only on mobile devices. Visit the same page with a mobile device and a desktop device to check if you see different ads.

Limitations

Cache and cache-busting are very advanced features and it is possible that some plugins and servers use too restrictive settings. Please let us know about it.

Compatibility warning (passive cache-busting)

The following warning in the ad parameter options of an ad might indicate a compatibility problem between the ad content and passive cache-busting.
The code of this ad might not work properly with activated cache-busting.
This might be a false positive and your ad works without problems, but if you use passive cache-busting for this ad you should check in the frontend to be sure.
A few reasons for this warning:
  • use of <?php ?> without the PHP option enabled
  • use of jQuery(document).ready()
  • use of any other JavaScript variable or object defined outside of the current ad

Header-Codes (ajax cache-busting)

Some ad networks require you to add come extra code into the <head> section of your theme. Delivering these kind of tags with cache busting might result in problems with your ad networks. We also lack a use case in which such dynamic header codes are needed, so please let us know if you have one.

You must not include ads between wp_head() and the </head> tag.

Caching and Cookies

Advanced Ads Pro might use cookies in order to send dynamic information to ads. Very restrictive types of caches might either remove those cookies in order to allow cache or set cookies might break the caching at all. Please ask the developer or your caching plugin or your hoster if you are not sure about this.

Cache-Busting in Widgets

In order to use cache-busting in widgets, you need to use the Sidebar Widget placement.

Only this placement type can be selected in the Advanced Ads widget and also the cache-busting setting will be honored.

No cache-busting within Feed or external sites

If you send out a feed or your content is promoted on external sites, cache-busting is not working and will fall back to not display the ad at all. If you want to display ads within your feed, rather create another ad with the appropriate display conditions.

Other questions about ajax cache-busting

How does cache-busting effect performance?

Ajac cache-busting certainly adds more load to the backend as the number of requests is increased.

To avoid issues with your provider and load times you should:

  • use passive cache-busting whenever possible
  • not use cache-busting on static positions: does a placement only serve a single ad and for any request? do not cache-bust it!
  • try to combine ads and position using javascript: fewer requests mean faster page load
  • use persistent object cache plugins like W3 Total Cache or em-object-cache to avoid excessive database load
  • bypass proxies for AJAX calls (especially the /wp-admin/admin-ajax.php path)

Does cache-busting work for all ads?

There are some issues with ad-codes that try to include multiple external scripts at once ( <script src="..">).

Please split those into multiple ads or do not use cache-busting on them.

You must not include ads between wp_head() and the </head> tag.

How are cache-busted ads loaded?

The ad content is retrieved from the backend and analysed.

Does it contain any external JavaScript ( <script src="..">)? Than it is loaded asynchronous due to browser limitations.

Otherwise ads block page load until they are loaded.

How to force asynchronous loading with cache-busting

Add the async parameter to the <script> tag like with <script async>.

My ads are loaded asynchronous (sometimes) but should be blocking!

Due to browser limitations there is a forced switch to load any ad asynchronous while an external script is included.

You certainly have a <script src=".."> loaded before your ad.

If possible add async (see above) to the troublesome ad or do not use cache-busting for it if possible.

Troubleshooting

While reading the Limitations & FAQ section might help to fix issues as well, here are a few quick ideas to check in case Cache-Busting doesn’t seem to work for you:

  • cache-busting also changes some markup in the frontend, so be sure to clear your cache after you changed cache-busting options or setup.
  • cache-busting only works when the ad or group is displayed using a Placement.
  • check for JavaScript errors in the frontend console. Those could break cache-busting too.

Debug mode

Cache-busting has its own debug mode, which you can enable by adding #debug=true to the current URL (and reload the page). The output is displayed in the JavaScript error console. If you don’t know what this means then this might be too technical for you. We are considering adding a simpler debug mode in the future.

The debug output contains information about cache-busting (AJAX and passive), site setup and which ads are loaded. That helps us to understand your setup without a login. No data is visible that other parties couldn’t also see without debug mode.

JS file Minification

When JavaScript files are minified by a script, plugin or hosting service, it might break how cache-busting works too. As a last measure, exclude the following files from minification:

  • /wp-content/plugins/advanced-ads-pro/modules/cache-busting/inc/postscribe.js
  • /wp-content/plugins/advanced-ads-pro/modules/cache-busting/inc/htmlParser.js
  • /wp-content/plugins/advanced-ads-pro/modules/cache-busting/inc/base.js
  • /wp-content/plugins/advanced-ads/public/assets/js/advanced.js

 Advanced Features