PriMoThemes — now s2Member® (official notice)

This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™

Cached files serve incorrect session

Quick Cache Plugin. Speeds up WordPress®.

Cached files serve incorrect session

Postby Jason » March 14th, 2011, 6:21 am

I have a shopping cart on my client's website, we cache the category and product pages and add items to the cart via AJAX - and the items in the cart are held in the session. Using Chrome's Web Inspector I can see that the php session seems to change from page to page. When I disable the Quick Cache plugin the session is held across page loads correctly.

Any idea what's going on or how I might be able to fix it?

Thanks!
User avatar
Jason
Registered User
Registered User
 
Posts: 3
Joined: March 14, 2011

Re: Cached files serve incorrect session

Postby markb1439 » March 14th, 2011, 4:10 pm

This is a common issue with shopping carts and cache plugins. One shopper is served the cached cart or other data from previous shoppers. Even with an ajax cart, there can still be issues with some carts.

There are various workarounds. One is to set Quick Cache not to serve the cart page, checkout page, etc. An additional method is to put a DONOTCACHE or similar directive in the cart widget, so any page containing it is not cached.

Which cart are you using?
User avatar
markb1439
Registered User
Registered User
 
Posts: 11
Joined: February 19, 2011

Re: Cached files serve incorrect session

Postby Jason » March 14th, 2011, 6:01 pm

I'm using WP e-Commerce.

I already turned off caching on the cart/checkout pages as I knew this would be a problem. I did not expect that the AJAX requests which add items to the cart would pick up the cached session (but the session id is held in a cookie, so that makes sense).

I'm wondering if there is a way of not caching the session id? (please forgive me if this is an ignorant question, I know not of Quick Cache's internals).
User avatar
Jason
Registered User
Registered User
 
Posts: 3
Joined: March 14, 2011

Re: Cached files serve incorrect session

Postby markb1439 » March 24th, 2011, 12:00 am

Hi,

I don't think there's a way to do that. Even if you excluded the session ID, that wouldn't exclude the sessions themselves from being cached, therein the problem.

What you really want to do (I think) is simply make sure that caching doesn't happen on a page where the cart exists. You can do this by adding a DONOTCACHE directive to the cart widget (in addition to excluding the pages you already know to exclude). Of course, if the cart widget is on every page, this means that you won't effectively be able to use the caching plugin at all (why install it if caching is never done).

Another option would be to find out the cookie used for items in cart, and set the directive to DONOTCACHE if the cart is not empty.

Which cart are you using (if I may ask)?

Hope this helps.

Mark
User avatar
markb1439
Registered User
Registered User
 
Posts: 11
Joined: February 19, 2011

Re: Cached files serve incorrect session

Postby Jason » March 24th, 2011, 2:24 am

I'm using WP e-Commerce - which can be quite slow when listing a bunch of products, and was the reason I wanted to use Quick Cache in the first place :(

Back to the drawing board.
User avatar
Jason
Registered User
Registered User
 
Posts: 3
Joined: March 14, 2011


Return to Quick Cache Plugin

Who is online

Users browsing this forum: No registered users and 1 guest

cron