I am trying to get varnish cache to work with SimpleCart, but for whatever reason varnish is ignoring the Simplecart cookies:
SimpleCart (served from .example.com instead of example.com)
SimpleCart_Recent (served from .example.com instead of example.com
Is there any sample configuration vcl file optimized for using it with SimpleCart? I assume the problem is caused by SimpleCart serving its cookies from the base domain with a leading dot instead of serving it from the original base url. The modx session cookie as well as other third party cookies are coming through without any issues. Is there any possibility to change this SimpleCart behavior.
That’s a very good question. I don’t immediately have an answer though!
SimpleCart should be defaulting to the MODX settings (e.g. session_cookie_domain), so if that’s set up correctly I’m not quite sure why that wouldn’t work.
The only reason I can think of on the spot is if you’re using a domain like localhost (a single domain without TLD), or if you’re running off a special port, in which case SimpleCart does some extra logic on the provided domain.
If you can send in a ticket to support@modmore.com with some more details I’d be happy to help investigate further.
So far, the only solution was to disable varnish caching completely. However it would be nice to use some varnish rules like for WooCommerce or other shopping components to optimize the performance even more…
Here’s the code to disable varnish (version 4) caching for your SimpleCart installation:
sub vcl_recv {
if (req.http.Host ~ "your\.domain\.com") {
if (req.http.Host == "your.domain.com") {
return(pass);
} else {
return (pass);
}
}
}
sub vcl_backend_response {
if (bereq.http.Host ~ "your\.domain\.com") {
return (deliver);
}
}