Hi @thomasjarvisdesign
Thank you for reaching out.
We have investigated the behavior and confirmed that ShopMagic can set a cookie called shopmagic_visitor_xyz, which may affect how caching works. This is expected to some extent, as the cookie is used as part of ShopMagic’s visitor tracking mechanism.
The cookie is normally set when a visitor adds a product to the cart and starts providing checkout information. ShopMagic uses two mechanisms for tracking visitors:
- WooCommerce session data
- Browser cookies
Both methods are used because WooCommerce sessions are temporary and their data can expire relatively quickly, while cookies can persist for up to one year and allow more reliable visitor identification.
That said, while reviewing the code, we noticed that there may be a potential issue where the cookie is being set more frequently than necessary in some cases. We are looking into this further to confirm whether this behavior can be improved.
As a temporary workaround, you can disable cookie-based tracking while keeping session tracking enabled by adding the following filter:
add_filter('shopmagic/core/customer_interceptor/cookies_enabled', '__return_false');
This will prevent ShopMagic from creating the visitor cookie, which should allow WP Rocket caching to work more consistently.
The alternative would be disabling session tracking entirely in ShopMagic settings, but we do not recommend this unless necessary, because it will prevent some functionality from working correctly, including abandoned cart tracking.
We will continue investigating whether there is a way to optimize this behavior on our side and will let you know if we find a better solution.
Thank you for investigating.
To confirm if I add the snippet in your post to functions.php and then re-enable:
“enable session tracking”
(This is under shop Magic > Settings > General)
It should prevent the cookie from generating and disrupting the cache.
What kind of ETA for investigation are we looking at?
On larger websites or sites with a high cache turnover (The kind that need shop magic) this is a huge problem.
WP-Rocket had been set to never clear cache on the site we are having the issue with – But the cache still wasnt being served. I would imagine a lot of your clients will have the same cache bypass problem and not be aware of it!
This has been the main contributing factor to this site failing web vitals in real world data. As the TTFB score has plummeted due to bypass of page cache.
To ensure the site runs fast all day we have the following running:
- WP-Rocket set to never clear unless instructed to
- Clear the cache early morning
- Run a private cache warmer on mobile and desktop useragents early morning
- The site stays cached all day without breaking the wp_sessions_ which has a lifespan of 48 hours.
Hi @thomasjarvisdesign
Yes, that’s correct. If you add the provided snippet to your functions.php file and then re-enable “Enable session tracking” in ShopMagic → Settings → General, it will prevent the cookie from being created and should no longer interfere with your page cache.
We will also investigate this behavior to determine whether it is caused by a bug. If we conclude that a fix is required, we’ll let you know once it has been implemented and released in a future update.
At the moment, I’m not able to provide a precise ETA for this investigation or a potential fix. We first need to address issues that were reported by other customers before yours, so we handle bug reports according to our development queue.
Thank you for bringing this to our attention and for your patience.