This is an old revision of the document!


Can you Exclude the Price Block from public Cache for Only the Logged-in Users?

You might have a situation where pricing varies per user and is fetched via API from an external ERP system. This system only applies to logged-in users. Users who are logged out should not see pricing at all.

For non-logged-in user:

For the logged-in user:

On product page click “login” to see the discounted prices from API. Fetch the prices directly from a external API solution to have separate customer pricing. There are two customer groups: group id 1 and group id 2. You would want the API price update for only one customer group 1 and store 1, but not group 2. How?

Caching pages with this kind of setup is tricky. LiteMage is able to cache different prices per customer group, but not per individual customers. For logged-in users, you could make the price block into a private ESI block and configure it to be uncacheable, but you can't treat the block differently for logged-in and non-logged-in users. A custom solution would be required.

Added CacheLookup private on in .htaccess after LiteMage on, looks like the following:

<IfModule Litespeed> 
LiteMage on 
CacheLookup private on
</IfModule>

Added below code to app/code/community/Litespeed/Litemage/Helper/Esi.php Line 1160 - 1164

/* customized code added by for case 1 */
        if ($currCustomerGroup == 1 && $currStoreId == 1) {
                  $this->_cacheVars['flag'] |= self::CHBM_PRIVATE;
        }
/* end of customized code change */

So for logged in user with group 1 and store 1, it should not be cached.

Updated LiteMage configuration:

Separate Cache Copy per Customer Group -> Yes
Flush Product and Categories When Product Qty Changes -> Only when stock status change

For “Flush Product and Categories When Product Qty Changes”, if you do not show qty on your product and cat pages, you don't need to flush it when qty change.

  • Admin
  • Last modified: 2017/12/18 17:29
  • by Jackson Zhang