Tips and Tricks HQ Support Portal › Forums › WP Affiliate Platform › Compatible with Pantheon's Varnish cache?
Tagged: cache, cache broken, cache not working, caching broken, pantheon varnish, varnish cache, varnish caching
- This topic has 3 replies, 3 voices, and was last updated 5 years, 4 months ago by admin.
-
AuthorPosts
-
July 22, 2019 at 3:07 pm #15490herbalacademyParticipant
Hi, we are using the WP Affiliate Platform plugin on our site hosted at Pantheon,theherbalacademy.com . We were recently notified by Pantheon support that the Varnish caching on our site is not working. I confirmed using Pantheon’s tool at:varnishcheck.pantheon.io/varnish/theherbalacademy.com that the site does not serve cached pages when the WP Affiliate Platform plugin is enabled. When I disable the plugin, the caching immediately begins to work.
Could you please confirm if there’s any way to get the plugin working with Pantheon’s Varnish cache? We are using version 5.9.6 of WP Affiliate Platform and 5.1.1 of WordPress on the live site, but I’ve also tested with the newest versions of WP Affiliate Platform and WordPress on our dev environment and the Varnish caching still broke once WP Affiliate Platform was enabled. Thanks in advance.
July 22, 2019 at 8:49 pm #79728wzpModeratorThe only two caching plugins that we “officially” support are WP Super Cache and W3 Total Cache:
- WP Super Cache:
- W3 Total Cache:
https://support.tipsandtricks-hq.com/forums/topic/using-the-plugins-with-w3-total-cache-plugin
For Varnish, you must determine if it can be configured in a manner similar to the two supported plugins.
If cached pages are served to visitors who clicked on an affiliate link, then the plugin won’t be able to do some tasks dynamically to do the commission tracking.
July 23, 2019 at 7:49 pm #79729herbalacademyParticipantHi, thanks for the response. Varnish caching is enabled on all sites hosted at Pantheon, so it isn’t possible to turn it off or switch to a different plugin. However, the docs for the two cache plugins provided a good starting point. I was able to trace the issue to wp_affiliate_platform1.php, lines 7-9:
Code:if (!isset($_SESSION)) {
session_start();
}This means that the session is started on every page load, whether or not the current page is an affiliate referral. When a PHP session is started, it disables the Varnish cache.
I was able to get the cache working by modifying the code like this:
Code:if ($_GET[‘ap_id’] || isset($_COOKIE[‘ap_id’] || isset($_COOKIE[‘cart_in_use’]) || isset($_COOKIE[‘eMember_in_use’]) ) {
if (!isset($_SESSION)) {
session_start();
}
}Can you see any issues with this approach or recommend a better way? Basically, I just want to make sure that the session is only started when needed for affiliate tracking or WP Affiliate Platform admin functions.
July 25, 2019 at 7:07 am #79730adminKeymasterWhat you have done looks fine to me. That should work fine.
-
AuthorPosts
- You must be logged in to reply to this topic.