Notice: There is no legacy documentation available for this item, so you are seeing the current documentation.
Yes it does! One of our number one frustrations with previous systems was the lack of support for aggressive caching. You often had to make a compromise: either have good caching and a fast site with no referral tracking, or successful referral tracking with little to no caching and a slow site.
In many cases, AffiliateWP will work with your caching plugin with no specific configuration changes needed. If you do encounter issues where visits or referrals aren’t tracking correctly, though, or your affiliates are having trouble logging in, it may be necessary to make a few changes to your caching settings.
Tip: Using Cloudflare, a CDN, Sucuri, or server-level caching such as Varnish or Redis? Please refer to the documentation for your specific provider for instructions on excluding URLs and cookies. If you use a caching plugin and Cloudflare together (or another provider, server-level caching, etc.), you’ll need to make the changes in both your caching plugin settings and your Cloudflare/other settings.
Recommended caching settings to troubleshoot tracking or login issues
The first step we recommend is excluding AffiliateWP’s cookies from caching. If the cookies are being cached, this could result in (1) visits and referrals not tracking at all, (2) visits and/or referrals being credited to the wrong affiliate, or (3) affiliates unable to log in or logged into the wrong account.
For most web hosts, AffiliateWP creates three cookies that should be excluded from caching:
- affwp_ref
- affwp_ref_visit_id
- affwp_campaign
For Pantheon, AffiliateWP creates the same three cookies as above but with names compatible with Pantheon’s cookie policy:
- wp_affwp_ref
- wp_affwp_ref_visit_id
- wp_affwp_campaign
For Cloudflare sites that do not have the Cloudflare plans (Business and Enterprise) that allow exclusions to be set, we have made similar changes as Pantheon to create the same three cookies with names compatible with Cloudflare’s recommendations as seen here – Cloudflare Docs – Automatic Platform Optimizatio
- wp_affwp_ref
- wp_affwp_ref_visit_id
- wp_affwp_campaign
To implement the CloudFlare cookie bypass completely, this requires a few entries in your active theme’s functions.php file (USE CAUTION!) or a code snippet plugin of your choice is recommended.
The first entry turns on the Cloudflare-specific cookie names:
add_filter( 'affwp_tracking_cookie_compat_mode', '__return_true' );
The second entry assures the affiliate_id is transported successfully through the WooCommerce order transaction:
add_filter( 'affwp_get_referring_affiliate_id', function( $affiliate_id, $reference, $context ) {
if ( 'woocommerce' === $context ) {
$affiliate_id = affiliate_wp()->tracking->get_affiliate_id();
}
return $affiliate_id;
}, 10, 3 );
If you are not integrating with WooCommerce, use this snippet in place of the above:
add_filter( 'affwp_get_referring_affiliate_id', function( $affiliate_id, $reference, $context ) {
$affiliate_id = affiliate_wp()->tracking->get_affiliate_id();
return $affiliate_id;
}, 10, 3 );
Next, we recommend excluding any AffiliateWP-related URLs from caching, and also script loading. This could include the following:
- The Affiliate Area page
- The affiliate registration page (if separate from the Affiliate Area)
- The affiliate login page (if separate from the Affiliate Area)
- Any pages using shortcodes from the Affiliate Area Shortcodes add-on
- The AffiliateWP tracking script (if you have js or scripting optimizations enabled that include lazy loading or deferred loading)
(https://mysite.com/wp-content/plugins/affiliate-wp/assets/js/tracking.min.js
)
The process to exclude the above cookies and URLs varies depending on which caching plugin you use. Below are the locations for those settings in several popular caching plugins.
WP Rocket
To exclude cookies and URLs in WP Rocket, navigate to Dashboard » Settings » WP Rocket » Advanced Rules.
- In the “Never cache URLs” field at the top, add the slugs for your pages.
- Add each of the three cookies, one per line, on the next field labeled “Never cache cookies.”
- Save your settings.
- Purge all caches.
Note: You can also disable settings per-page with WP Rocket on the right sidebar, so that might be an option as well for specific pages that are not performing as intended.
Need help with your WP Rocket settings? You can contact their support team here.
NitroPack
To exclude cookies and URLs in NitroPack, log into your NitroPack dashboard and follow these steps:
- Click on the Settings tab.
- Scroll down to Excluded URLs and click the toggle to enable (if not already enabled).
- Enter the URL of your affiliate area page.
- Scroll down a bit more to Excluded Cookies and click the toggle to enable (if not already enabled).
- Click the Add Cookie button and enter the following:
- Cookie name: affwp_ref / Cookie value: (leave blank)
- Cookie name: affwp_ref_visit_id / Cookie value: (leave blank)
- Cookie name: affwp_campaign / Cookie value: (leave blank)
- Scroll back to the top and click the Save Settings button.
- Go back to the main dashboard screen and click the Purge Cache button.
Need help with your NitroPack settings? You can contact their support team here.
WP Fastest Cache
To exclude cookies and URLs in WP Fastest Cache, navigate to Dashboard » WP Fastest Cache » Exclude tab.
- Click the “Add New Rule” button next to Exclude Pages to add the slugs for your pages.
- Click the “Add New Rule” button next to Exclude Cookies to add each of the three cookies.
- Save your settings.
- Purge all caches.
Need help with your WP Fastest Cache settings? You can contact their support team here for the free plugin or here for the premium version.
Breeze
To exclude cookies and URLs in Breeze, navigate to Dashboard » Settings » Breeze » Advanced Options tab.
- In the “Never cache these URLs” field at the top, add the URLs for your pages.
- Breeze does not have cookie-specific settings built into the plugin, so we recommend contacting their support team for assistance if needed.
- If you are using Varnish on a Cloudways server alongside the Breeze plugin, it’s possible to exclude the cookies and URLs directly within your Varnish settings. Please refer to this article from Cloudways for instructions on excluding URLs. Refer to this one for instructions on excluding cookies.
- Save your settings.
- Purge all caches. If you use Varnish, please check in Dashboard » Settings » Breeze » Varnish to ensure the “Auto Purge Varnish” option is enabled.
Need help with your Breeze settings? If you are a Cloudways user, please log into your Cloudways account to use live chat or open a ticket; if you use a different web host, you can seek support here.
LiteSpeed Cache
To exclude cookies and URLs in LiteSpeed Cache, navigate to Dashboard » LiteSpeed Cache » Cache » Excludes tab.
- In the “Do Not Cache URIs” field, add the slugs for your pages.
- In the “Do Not Cache Cookies” field, add each of the three cookies, one per line.
- Save your settings.
- Purge all caches.
Need help with your LiteSpeed Cache settings? If you use the premium plugin, you can open a support request here, or you can go here if you use the free version.
W3 Total Cache
To exclude cookies and URLs in W3 Total Cache, navigate to Dashboard » Performance » Page Cache.
- In the “Never cache the following pages” field, add the slugs for your pages.
- Scroll down to the “Rejected cookies” field and add each of the three cookies, one per line.
- Save your settings.
- Purge all caches.
Need help with your W3 Total Cache settings? You can contact their support team here for the free plugin or here for the premium version.
Once the cookie and URL exclusions are in place, please purge all caches and follow the
steps to test a visit and referral. Still not working? Let us know and we’ll be glad to help!