How does Affiliate for WooCommerce plugin work with caching

Affiliate for WooCommerce plugin helps you to add, manage affiliates, and track performance from a single place – commissions, sales, payouts, leaderboard, etc. Earn money without hard work. Increase your brand outreach, and get potential customers.

It’s common for store owners to use caching solutions to boost website loading times.

The Affiliate for WooCommerce plugin usually functions seamlessly with most caching plugins. However, in some instances, caching can cause the affiliate tracking to not work as expected, leading to lost commissions for affiliates.

Important

Make sure that the Affiliate for WooCommerce plugin is up-to-date (learn more). You can see the changes included in each update in the changelog.

Why does caching affect referral tracking?

↑ Back to top

Affiliate referral tracking relies on cookies to track purchases through referral links or referral coupons.

Caching creates static versions of your web pages to speed up load times, but this can sometimes prevent dynamic features, such as cookie-based referral tracking, from working correctly.

So, when referral links or cookies are cached, registering referrals might fail.

If you encounter any such issues, you may need to make a few changes to your caching plugin setting to exclude specific pages and cookies from caching as mentioned below:

Excluding plugin URLs from caching

↑ Back to top

If the referral URLs are being cached, it may affect referral tracking, so we recommend excluding them from caching.

Also, we recommend excluding the following pages from caching, and script loading:

Excluding Affiliate for WooCommerce cookies from caching

↑ Back to top

The Affiliate for WooCommerce plugin relies on cookies for referral tracking. It saves the cookies in the visitor’s browser when someone visits an affiliate referral link or applies a referral coupon.

Please refer to this FAQ to learn more about the names and the purposes of the cookies.

If these cookies are being cached, it may result in disabling referral tracking, so we recommend excluding them from caching.

How do we exclude the URLs and cookies from caching?

↑ Back to top

Excluding URLs and cookies from caching depends on which caching plugin you use.

WP Rocket

↑ Back to top

Follow these steps to exclude a page(s) from the cache.

  1. Go to WordPress admin > Settings > WP Rocket > Advanced Rules tab.
  2. Find the box ‘Never Cache URL(s)’.
  3. Add the URLs as guided in the WP Rocket documentation.
  4. Save the settings.

To exclude the cookies, follow these steps:

  1. Go to WordPress admin > Settings > WP Rocket > Advanced Rules tab.
  2. Enter the cookies mentioned above inside the box Never cache Cookies.
  3. Save the settings.

LiteSpeed Cache

↑ Back to top
  1. Go to WordPress admin > LiteSpeed Cache > Cache > Excludes tab.
  2. In the ‘Do Not Cache URIs’ field, add the slugs to exclude URLs.
  3. In the ‘Do Not Cache Cookies’ field, add cookie names.
  4. Save the settings.
  5. Purge all caches.

W3 Total Cache

↑ Back to top
  1. Go to WordPress admin > Performance > Page Cache > Advanced tab.
  2. In the ‘Never cache the following pages’ field, add the slugs to exclude URLs.
  3. In the ‘Rejected cookies’ field, add cookie names.
  4. Save the settings.
  5. Purge all caches.

WP Fastest Cache

↑ Back to top
  1. Go to WordPress admin > WP Fastest Cache > Exclude tab.
  2. Add a new rule to exclude URLs.
  3. Add a new rule to exclude cookies and enter cookie names.
  4. Save the settings.
  5. Clear all caches.

NitroPack

↑ Back to top
  1. You can exclude URLs by following this doc.
  2. You can exclude from optimization by Cookie by following this doc.

For more information, please refer to the documentation of your specific caching plugin.

Excluding Cookies on the Hosting Side

↑ Back to top

Many managed hosting providers and CDNs use full-page server-side caching (such as Varnish, NGINX FastCGI Cache, or CDN HTML caching) to improve performance.

While this is great for speed, it can interfere with affiliate tracking.

Affiliate tracking relies on PHP execution and browser cookies. If a cached HTML page is served before PHP runs, the affiliate tracking logic never executes, and the tracking cookies are never set.

In that case, the tracking fails for real users.

If tracking works when you are logged in as a store admin but fails for real users, server-side caching could be the culprit.

Why is cache bypass required?

↑ Back to top

To ensure affiliate tracking works reliably:

  • Pages must not be served from the full-page cache when referral logic is required.
  • PHP must execute on the initial visit so the affiliate cookie can be set.
  • Cached versions of pages must be bypassed when referral parameters are present.

The cookies for affiliate tracking

↑ Back to top

Affiliate for WooCommerce uses the following cookies for referral tracking:

Cookie names: affiliate_for_woocommerce, afwc_hit, afwc_campaign (learn more).
Action required: These cookies must be allowed to pass through the caching layer and, more importantly, pages must bypass cache when these cookies or referral parameters are present.

If you’re unsure, contact your hosting provider and ask them to whitelist the tracking cookies or ensure that dynamic content (like referral tracking) is served correctly.

Copy-Paste request to contact hosting support

↑ Back to top

You can send the following message to your hosting provider’s support team:

Hello,

I am using an affiliate plugin on my site (insert website link here) that relies on PHP execution and cookies for referral tracking.

Please whitelist the cookies named affiliate_for_woocommerce, afwc_hit, and afwc_campaign (learn more) from your server-side caching (Varnish/NGINX/Object Cache).

Additionally, please ensure that any URL containing the query parameters ?ref= or ?coupon= bypasses the caching entirely to ensure tracking logic executes.

Note: ref is the default tracking param name. If you have changed it, kindly share it accordingly.

Once the cookies are excluded from caching, tracking works reliably.

Cloudflare (CDN)

↑ Back to top

Cloudflare caches HTML aggressively and may ignore cookies, which can prevent the affiliate cookie from being set and result in missing referrals.

  • Use Cache Rules to bypass caching for referral URLs and registration pages.
  • Create a rule to Bypass Cache when affiliate cookies or referral parameters are present (?ref=, ?coupon=).
  • Ensure Cloudflare does not cache or overwrite the referral tracking cookies.

Kinsta

↑ Back to top

Kinsta’s full-page caching may block tracking cookies unless explicitly whitelisted. Their cache may deliver a cached page before the cookie is set.

  • Contact Kinsta support and ask them to whitelist the referral tracking cookies.
  • Request exclusion for affiliate referral URLs and any page with referral parameters.

WP Engine

↑ Back to top

WP Engine’s EverCache can serve cached pages even when referral parameters are present. It also removes cookies unless specifically allowed.

  • Ask WP Engine support to bypass the cache for URLs containing referral parameters.
  • Request a whitelist for all referral tracking cookies.

SiteGround

↑ Back to top

SiteGround’s Dynamic Cache and built-in CDN can override referral cookies. It may serve cached HTML before cookies are set.

  • Disable Dynamic Cache for landing pages or add cookie exclusions.

Bluehost / GoDaddy / HostGator (Shared Hosting)

↑ Back to top

Many shared hosts use server-level caching that ignores cookies and may prevent them from being set unless manually allowed.

Contact and ask for support to:

  • Whitelist cookies from the plugin.
  • Exclude landing pages from full-page caching.

Varnish Cache

↑ Back to top

Varnish ignores cookies by default unless explicitly configured. This breaks affiliate tracking.

Contact hosting to:

  • Allow the cookies to pass through.
  • Bypass cache when referral parameters exist.

NGINX FastCGI Cache

↑ Back to top

NGINX may serve cached pages before cookies can be applied. It caches everything unless cookie exceptions are set.

Developers should ensure:

  • Cache bypass for cookies from the plugin.
  • Referral parameters (?ref=, ?coupon=) bypass cache.

Final Tips

↑ Back to top

Caching levels: Some plugins offer different caching levels (e.g., page cache, object cache). Ensure you’re excluding data at the appropriate level.

Advanced caching rules: Caching plugins might offer advanced options for more granular control. Refer to your plugin’s documentation for details.

Change cookies names: If you need to change cookie names to support any specific web hosting (for example, Flywheel hosting), or anything else, you may check this FAQ.

Testing: After implementing changes, test your affiliate tracking functionality to ensure proper referral attribution.

Regular update: Regularly update your caching plugin’s settings when changes are made to your referral structure.

Hosting provider: Contact your hosting provider for assistance if cookie whitelisting is required.

By following these simple steps, you can ensure that your affiliate program runs smoothly without interference from caching mechanisms.

FAQs

↑ Back to top

1. What to do if all the visitor’s IP address is the same as your hosting’s IP address?

↑ Back to top

If you use Varnish cache or a similar system, it listens on port 80 and passes data to the default HTTP application; it means that the HTTP log files will show your server’s IP instead of the actual remote IP of the visitor.

Visit this doc to learn how to pass a visitor’s IP address from Varnish/similar system to WordPress, so the actual IP address of the visitor is recorded.

Facing any issues?

↑ Back to top

Feel free to contact your hosting provider or us from here for assistance.

Feature request

↑ Back to top

Have a feature request or enhancement suggestion for Affiliate For WooCommerce? Submit it from here: Submit a feature request.

Related Products

Let customers subscribe to your products or services and pay on a weekly, monthly or annual basis.

Power your membership association, online magazine, elearning sites, and more with access control to content/products and member discounts.