Exclude cookies does not seem to be working

#1
Hi,

Website : https://myboatcard.com/
Test affiliate link : https://myboatcard.com/card/6/

We are trying to use AffiliateWP but Litespeed cache seems to stop tracking affiliate referrals.

AffiliateWP says it does work with Litespeed.
https://affiliatewp.com/docs/does-a...rt here.-,LiteSpeed Cache,-To exclude cookies

But the affiliate tracking only works on first visit after purging all or when cache is turned off.

Any ideas on what might be stopping affiliatewp from working even with the items excluded from caching?

We have added the following URL excludes :
/affiliate-area/
/affiliate-login/
/affiliate-terms-and-conditions/
wp-.*\.php
index\.php
/become-an-affiliate*
/affiliate-dashboard*
/affiliate-area*
/become-an-affiliate/
/affiliate-dashboard/
/lets-keep-in-touch/
/login/
/my-account/
/registration/`

And the following cookie excludes:
affwp_ref
affwp_ref_visit_id
affwp_campaign
wptouch_switch_toggle
wp-affwp_ref_visit_id
wp-affwp_ref
wp-affwp_campaign


Thanks
 

serpent_driver

Well-Known Member
#2
You are using quic.cloud and it seems that QC doesn't honor cookie exclude rules in .htaccess. Otherwise all URLs would be excluded from caching if any of these affiliate cookies is set. The URL to test affiliate link is not cached, but not because of the cookie, but this URL seems to be excluded from caching. To test if I am right you would have to disable QC for testing.

Basically the exclude from caching with cookies works!

In my mind your method to get AffiliateWP to work is wrong. You don't need to exclude from caching with cookies, because all URLs are excluded from caching if the affiliate cookie is set. It should be enough to exclude URLs with certain $_GET paramter from being cached, so the affiliate cookie can be set and this cookie should be everything you need. A specific URL for a landing page should also be okay, but the URLs from above are wrong. "*" isn't supported.
 
Last edited:
#3
Thanks for your reply.

We went ahead and just excluded the following URIs "/card" - which stops cache on the affiliate link landing pages : https://myboatcard.com/card/6/

But one of the main features we wanted to use affiliatewp for was its direct tracking feature which sets affiliate cookie if user is referred from a specific url (and is not using a affiliate url such as https://myboatcard.com/card/6/).

https://affiliatewp.com/add-ons/pro/direct-link-tracking/

Is there a way for this to work on the regular homepage : https://myboatcard.com
 
#5
thanks .. would you be able to tell us what the sample code is that we would need to add to .htaccess file to exclude a specific referring URL from cache.

Thanks
 

serpent_driver

Well-Known Member
#6
For single referrer:

Apache config:
<IfModule LiteSpeed>
    RewriteCond %{HTTP_REFERER} domain\.com [NC]
    RewriteRule .* - [E=Cache-Control:no-cache]
</IfModule>
For multiple referrer:

Apache config:
<IfModule LiteSpeed>
    RewriteCond %{HTTP_REFERER} domain\.com [NC,OR]
    RewriteCond %{HTTP_REFERER} anotherdomain\.com [NC]
    RewriteRule .* - [E=Cache-Control:no-cache]
</IfModule>
 
#7
Thanks.

I added :

<IfModule LiteSpeed>
RewriteCond %{HTTP_REFERER} freewebsitedesign\.ca [NC,OR]
RewriteCond %{HTTP_REFERER} dmboatsales\.com
RewriteRule .* - [E=Cache-Control:no-cache]
</IfModule>

But when clicking on MyBoatCard.com link in freewebsitedesign.ca the MyBoatCard.com homepage does not cache
 
#11
i placed it at the bottom of the .htaccess file :


# BEGIN LSCACHE
## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##
<IfModule LiteSpeed>
RewriteEngine on
CacheLookup on
RewriteRule .* - [E=Cache-Control:no-autoflush]
RewriteRule \.litespeed_conf\.dat - [F,L]

### marker NOCACHE COOKIES start ###
RewriteCond %{HTTP_COOKIE} affwp_ref|affwp_ref_visit_id|affwp_campaign|wptouch_switch_toggle|wp\-affwp_ref_visit_id|wp\-affwp_ref|wp\-affwp_campaign
RewriteRule .* - [E=Cache-Control:no-cache]
### marker NOCACHE COOKIES end ###

### marker CACHE RESOURCE start ###
RewriteRule wp-content/.*/[^/]*(responsive|css|js|dynamic|loader|fonts)\.php - [E=cache-control:max-age=3600]
### marker CACHE RESOURCE end ###

### marker FAVICON start ###
RewriteRule favicon\.ico$ - [E=cache-control:max-age=86400]
### marker FAVICON end ###

### marker WEBP start ###
RewriteCond %{HTTP_ACCEPT} "image/webp"
RewriteRule .* - [E=Cache-Control:vary=%{ENV:LSCACHE_VARY_VALUE}+webp]
RewriteCond %{HTTP_USER_AGENT} iPhone.*Version/(\d{2}).*Safari
RewriteCond %1 >13
RewriteRule .* - [E=Cache-Control:vary=%{ENV:LSCACHE_VARY_VALUE}+webp]
### marker WEBP end ###

### marker DROPQS start ###
CacheKeyModify -qs:fbclid
CacheKeyModify -qs:gclid
CacheKeyModify -qs:utm*
CacheKeyModify -qs:_ga
### marker DROPQS end ###

</IfModule>
## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##
# END LSCACHE
# BEGIN NON_LSCACHE
## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##
### marker BROWSER CACHE start ###
<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType application/pdf A31557600
ExpiresByType image/x-icon A31557600
ExpiresByType image/vnd.microsoft.icon A31557600
ExpiresByType image/svg+xml A31557600

ExpiresByType image/jpg A31557600
ExpiresByType image/jpeg A31557600
ExpiresByType image/png A31557600
ExpiresByType image/gif A31557600
ExpiresByType image/webp A31557600

ExpiresByType video/ogg A31557600
ExpiresByType audio/ogg A31557600
ExpiresByType video/mp4 A31557600
ExpiresByType video/webm A31557600

ExpiresByType text/css A31557600
ExpiresByType text/javascript A31557600
ExpiresByType application/javascript A31557600
ExpiresByType application/x-javascript A31557600

ExpiresByType application/x-font-ttf A31557600
ExpiresByType application/x-font-woff A31557600
ExpiresByType application/font-woff A31557600
ExpiresByType application/font-woff2 A31557600
ExpiresByType application/vnd.ms-fontobject A31557600
ExpiresByType font/ttf A31557600
ExpiresByType font/otf A31557600
ExpiresByType font/woff A31557600
ExpiresByType font/woff2 A31557600

</IfModule>
### marker BROWSER CACHE end ###

## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##
# END NON_LSCACHE
#This Apache config file was created by Duplicator Installer on 2022-03-01 21:09:20.
#The original can be found in archived file with the name .htaccess__[HASH]
# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

<IfModule LiteSpeed>
RewriteCond %{HTTP_REFERER} freewebsitedesign\.ca [NC,OR]
RewriteCond %{HTTP_REFERER} dmboatsales\.com
RewriteRule .* - [E=Cache-Control:no-cache]
</IfModule>

# END WordPress
# BEGIN WP Cloudflare Super Page Cache
# The directives (lines) between "BEGIN WP Cloudflare Super Page Cache" and "END WP Cloudflare Super Page Cache" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
# END WP Cloudflare Super Page Cache
 

serpent_driver

Well-Known Member
#13
Remove this from your .htacces or the aff* cookies.

Apache config:
### marker NOCACHE COOKIES start ###
RewriteCond %{HTTP_COOKIE} affwp_ref|affwp_ref_visit_id|affwp_campaign|wptouch_switch_toggle|wp\-affwp_ref_visit_id|wp\-affwp_ref|wp\-affwp_campaign
RewriteRule .* - [E=Cache-Control:no-cache]
### marker NOCACHE COOKIES end ###
 
#15
Hi,

### marker NOCACHE COOKIES start ###
RewriteCond %{HTTP_COOKIE} affwp_ref|affwp_ref_visit_id|affwp_campaign|wptouch_switch_toggle|wp\-affwp_ref_visit_id|wp\-affwp_ref|wp\-affwp_campaign
RewriteRule .* - [E=Cache-Control:no-cache]
### marker NOCACHE COOKIES end ###


the above was created by LS plugin (we did not add it to htaccess) when exclude cookies were added in the dashboard of the plugin
do you want me to remove the cookie excludes from plugin dashboard?

to purge cache in quic cloud - do we purge all in LS plugin or purge all in quic.cloud itself?

thanks
 

serpent_driver

Well-Known Member
#17
Do purge all in plugin should be enough. QC checks cache status of your host frequently.

You should remove aff* cookies from no-cache rules. If you don't do it you can't verify if referrer rule works.
 
#18
Thanks. I removed cookies and purged all and purged/flushed in quic.cloud

But https://myboatcard.com/ is still cached when referred by https://freewebsitedesign.ca/

Current htaccess:

# BEGIN LSCACHE
## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##
<IfModule LiteSpeed>
RewriteEngine on
CacheLookup on
RewriteRule .* - [E=Cache-Control:no-autoflush]
RewriteRule \.litespeed_conf\.dat - [F,L]

### marker CACHE RESOURCE start ###
RewriteRule wp-content/.*/[^/]*(responsive|css|js|dynamic|loader|fonts)\.php - [E=cache-control:max-age=3600]
### marker CACHE RESOURCE end ###

### marker FAVICON start ###
RewriteRule favicon\.ico$ - [E=cache-control:max-age=86400]
### marker FAVICON end ###

### marker WEBP start ###
RewriteCond %{HTTP_ACCEPT} "image/webp"
RewriteRule .* - [E=Cache-Control:vary=%{ENV:LSCACHE_VARY_VALUE}+webp]
RewriteCond %{HTTP_USER_AGENT} iPhone.*Version/(\d{2}).*Safari
RewriteCond %1 >13
RewriteRule .* - [E=Cache-Control:vary=%{ENV:LSCACHE_VARY_VALUE}+webp]
### marker WEBP end ###

### marker DROPQS start ###
CacheKeyModify -qs:fbclid
CacheKeyModify -qs:gclid
CacheKeyModify -qs:utm*
CacheKeyModify -qs:_ga
### marker DROPQS end ###

</IfModule>
## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##
# END LSCACHE
# BEGIN NON_LSCACHE
## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##
### marker BROWSER CACHE start ###
<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType application/pdf A31557600
ExpiresByType image/x-icon A31557600
ExpiresByType image/vnd.microsoft.icon A31557600
ExpiresByType image/svg+xml A31557600

ExpiresByType image/jpg A31557600
ExpiresByType image/jpeg A31557600
ExpiresByType image/png A31557600
ExpiresByType image/gif A31557600
ExpiresByType image/webp A31557600

ExpiresByType video/ogg A31557600
ExpiresByType audio/ogg A31557600
ExpiresByType video/mp4 A31557600
ExpiresByType video/webm A31557600

ExpiresByType text/css A31557600
ExpiresByType text/javascript A31557600
ExpiresByType application/javascript A31557600
ExpiresByType application/x-javascript A31557600

ExpiresByType application/x-font-ttf A31557600
ExpiresByType application/x-font-woff A31557600
ExpiresByType application/font-woff A31557600
ExpiresByType application/font-woff2 A31557600
ExpiresByType application/vnd.ms-fontobject A31557600
ExpiresByType font/ttf A31557600
ExpiresByType font/otf A31557600
ExpiresByType font/woff A31557600
ExpiresByType font/woff2 A31557600

</IfModule>
### marker BROWSER CACHE end ###

## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##
# END NON_LSCACHE
#This Apache config file was created by Duplicator Installer on 2022-03-01 21:09:20.
#The original can be found in archived file with the name .htaccess__[HASH]
# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

<IfModule LiteSpeed>
RewriteCond %{HTTP_REFERER} freewebsitedesign\.ca [NC,OR]
RewriteCond %{HTTP_REFERER} dmboatsales\.com
RewriteRule .* - [E=Cache-Control:no-cache]
</IfModule>

# END WordPress
# BEGIN WP Cloudflare Super Page Cache
# The directives (lines) between "BEGIN WP Cloudflare Super Page Cache" and "END WP Cloudflare Super Page Cache" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
# END WP Cloudflare Super Page Cache
 
#20
thanks. i placed it at the top and purged all - no luck still cached. I also tested by putting quic into maintenance mode.


<IfModule LiteSpeed>
RewriteCond %{HTTP_REFERER} freewebsitedesign\.ca [NC,OR]
RewriteCond %{HTTP_REFERER} dmboatsales\.com
RewriteRule .* - [E=Cache-Control:no-cache]
</IfModule>

# BEGIN LSCACHE
## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##
<IfModule LiteSpeed>
RewriteEngine on
CacheLookup on
RewriteRule .* - [E=Cache-Control:no-autoflush]
RewriteRule \.litespeed_conf\.dat - [F,L]

### marker CACHE RESOURCE start ###
RewriteRule wp-content/.*/[^/]*(responsive|css|js|dynamic|loader|fonts)\.php - [E=cache-control:max-age=3600]
### marker CACHE RESOURCE end ###

### marker FAVICON start ###
RewriteRule favicon\.ico$ - [E=cache-control:max-age=86400]
### marker FAVICON end ###

### marker WEBP start ###
RewriteCond %{HTTP_ACCEPT} "image/webp"
RewriteRule .* - [E=Cache-Control:vary=%{ENV:LSCACHE_VARY_VALUE}+webp]
RewriteCond %{HTTP_USER_AGENT} iPhone.*Version/(\d{2}).*Safari
RewriteCond %1 >13
RewriteRule .* - [E=Cache-Control:vary=%{ENV:LSCACHE_VARY_VALUE}+webp]
### marker WEBP end ###

### marker DROPQS start ###
CacheKeyModify -qs:fbclid
CacheKeyModify -qs:gclid
CacheKeyModify -qs:utm*
CacheKeyModify -qs:_ga
### marker DROPQS end ###

</IfModule>
## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##
# END LSCACHE
# BEGIN NON_LSCACHE
## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##
### marker BROWSER CACHE start ###
<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType application/pdf A31557600
ExpiresByType image/x-icon A31557600
ExpiresByType image/vnd.microsoft.icon A31557600
ExpiresByType image/svg+xml A31557600

ExpiresByType image/jpg A31557600
ExpiresByType image/jpeg A31557600
ExpiresByType image/png A31557600
ExpiresByType image/gif A31557600
ExpiresByType image/webp A31557600

ExpiresByType video/ogg A31557600
ExpiresByType audio/ogg A31557600
ExpiresByType video/mp4 A31557600
ExpiresByType video/webm A31557600

ExpiresByType text/css A31557600
ExpiresByType text/javascript A31557600
ExpiresByType application/javascript A31557600
ExpiresByType application/x-javascript A31557600

ExpiresByType application/x-font-ttf A31557600
ExpiresByType application/x-font-woff A31557600
ExpiresByType application/font-woff A31557600
ExpiresByType application/font-woff2 A31557600
ExpiresByType application/vnd.ms-fontobject A31557600
ExpiresByType font/ttf A31557600
ExpiresByType font/otf A31557600
ExpiresByType font/woff A31557600
ExpiresByType font/woff2 A31557600

</IfModule>
### marker BROWSER CACHE end ###

## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##
# END NON_LSCACHE
#This Apache config file was created by Duplicator Installer on 2022-03-01 21:09:20.
#The original can be found in archived file with the name .htaccess__[HASH]
# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>


# END WordPress
# BEGIN WP Cloudflare Super Page Cache
# The directives (lines) between "BEGIN WP Cloudflare Super Page Cache" and "END WP Cloudflare Super Page Cache" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
# END WP Cloudflare Super Page Cache
 
Top