1

I'm struggling to find a way to completely disable varnish for logged in users using the Turpentine extension.

I have a member based site, non-logged in guests can browse products but not see prices or order. Logged in members of course can.

I'm trying to use Varnish so the large numbers of non-members visiting the site don't impact the performance on the relatively small number of logged in members.

Out of the box once varnish is working properly with Turpentine the problem is that the product information starts to be cached and becomes visible to non-logged in users, or vice versa - a guest view can be shown to a logged in user.

So the question is:

Is there a block level syntax that can be added to local.xml or turpentine_esi.xml that will disable all caching for a logged in user?

Here's what I've tried

  1. Using my themes local.xml at first I tried shifting all the product_list blocks into a private ESI like this

    ...    
    <catalog_category_default>
     <reference name="product_list">
        <action method="setEsiOptions">
            <params>
                <access>private</access>
                <scope>page</scope>
                <flush_events>
                    <checkout_onepage_controller_success_action/>
                    <sales_quote_save_after/>
                </flush_events>
            </params>
        </action>
     </reference>
    </catalog_category_default>
    

However that returns the same "no products found" message to all visitors and even if I had got that working the number of blocks to shift over to private would become huge as I tried to catch every scenario where members only info might appear - even if I managed to find them all I could imagine the varnish caching and flushing could create more load than not having it at all.

  1. Next I tried disabling caching entirely for members - my prefered option anyway

    <customer_logged_in>
        <turpentine_cache_flag value="0"/>
    </customer_logged_in>
    

That didn't seem to have any effect at all, I was still getting cached content, and cached content was 'bleeding' between users.

6
  • It looks like (at least 2 years ago) this couldn't be done: github.com/nexcess/magento-turpentine/issues/50 github.com/nexcess/magento-turpentine/issues/103 I'm hoping something's changed since then!
    – benz001
    Dec 9, 2014 at 2:21
  • So what is the real issue here? Is some information that is normally visible not available to anonymous users? If so, what exactly and what is still cacheable?
    – user4351
    Dec 9, 2014 at 7:48
  • There are a multitude of blocks that need to be hidden (product prices, some categories, stock availability etc etc) but none of those blocks are rendered for guests with the current theme - hence the key question is can all caching be disabled for a logged in user?
    – benz001
    Dec 9, 2014 at 8:04
  • 1
    Probably the easiest way to do this is to create a second cookie. Then use that to segment cache contents. The presence of that cookie would then store two different versions of each page in varnish. It's not the same as completely disabling varnish but it fits your requirements.
    – user4351
    Dec 9, 2014 at 8:33
  • I'd been thinking that, but the technical notes in the turpentine repo alluded to a number of subtle issues when going down that path - may still have to try though, but still hoping there may be a solution using turpentine's existing features
    – benz001
    Dec 9, 2014 at 8:56

0

Browse other questions tagged or ask your own question.