Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Background on the problem

I have a WooCommerce site hosted on WPEngine. Before going live, I contacted support with a list of pages to exclude from caching. I tested the checkout functionality, everything worked fine.

Yesterday I checked Google Analytics and noticed that not a single Chrome user proceeded through the funnel to the checkout page after adding to cart. Panicked, I started investigating.

It turns out that add to cart doesn't work only in Chrome and only when not logged in. By doesn't work, I mean that the page reloads with the ?add-to-cart=xxx string, but the cart is empty - exactly what happens when the caching isn't disabled. Tried Chrome on different PCs, clearing browser cache, but the problem was reproduced on each PC exactly the same.

I thoroughly tested my site before launch in all desktop and mobile browsers. I never caught this problem because Chrome is my day-to-day browser and I'm always logged in.

What caused this problem?

I submitted a ticked about this yesterday and got a reply today stating that "this is actually a common issue" and I needed to provide them with a list of pages to exclude from caching (which was already done). The problem has also mysteriously disappeared.

Is this truly a common problem? Before submitting the ticket, I googled it, searched WordPress forums, this stack exchange, but came up with nothing.

It may be fixed, but I'd like to know what could've caused this. Can anyone shed any light on this?

share|improve this question
    
Maybe an AJAX issue with Webkit? Do you have statistics about Safari? –  toscho Apr 18 '13 at 16:59
    
Nothing for desktop Safari, but mobile Safari was fine when tested on iPhone 4S. –  Stan Apr 18 '13 at 17:06
1  
There is a Network tab in Chrome’s Developer Tools. You should see there which response is cached. –  toscho Apr 18 '13 at 17:08
    
You mean local cache, right? I tested the site with a freshly cleared cache yesterday. I don't believe Dev Tools can help you find out if the response has been cached by Varnish/W3TC - or am I wrong? –  Stan Apr 18 '13 at 17:41
    
First you have to check if it is a browser issue. You need the HTTP headers for that. Try it. –  toscho Apr 18 '13 at 17:43
show 1 more comment

2 Answers

I've been a user of WPengine for almost 2 years, and in the beginning I had the same experience: had to open a ticket to make WooCommerce work. It took almost a week, but after that it was perfect. Now I´m using my own server, with NginX and some apps for aggressive caching, and that Ajax button wot´t work anyway. I just unable it and everything is fine. I think WPengine won't tell the fix because it´s about their internal set up, and woo commerce and nginx/varnish is a little annoying to set up, so I think they won't offer their knowledge, like everyone that could handle this set up is doing too.

share|improve this answer
add comment

If all pages are cached, and you, as the first user arriving at the site, view the cart, you will see an empty cart, because it's empty, nothing has been added yet.

If you then go and look at a product and add it to the cart, then go to the cart page, you will see a cached copy of what you saw earlier, which was an empty cart. The cart in this case is just like any other page, it gets saved when it's generated and sent, and the copy is whats sent on future requests. Caching doesn't know that the cart is special, it's not psychic.

So if we exclude the cart from caching, a new copy is generated each time, and what you see is always up to date, rather than a stale out of date copy being served.

An analogy:

You ask your friend how many cats their parents have, and you're told 0. This is a travesty! You immediately send 4 cats and a dog to their parents, then immediately phone your friend up and ask the question again.

Your friend again says 0. They don't know you've sent their parent pets, but you know for a fact, the correct answer is 5 ( 4 cats + 1 dog ). They haven't received a call yet saying "omg these cats and dogs came in the post?!". How could they possibly know?

In this scenario, your friend is the cache. Excluding those pages from cache is like being given a hotline directly to your friends parents so you can ask from the source. You cant do this for every page as it's quicker/cheaper/faster to use a cache, in the same way it's easier to say "heres something I prepared earlier"

But it mysteriously started working with no changes on my end

No

You contacted your host, they asked you for a list of pages to exclude from caching, and they went and excluded those pages from caching. The same pages that suddenly mysteriously started to work.

The details of exactly how their cache works, be it HTTP modified headers, CDNs, partial or full page caches, is WPEngine specific, and varies from browser to browser, and server to server. I know that Chrome can sometimes be quite aggressive at caching things.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.