Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customer specific prices are cached #1535

Open
onigunn opened this issue Mar 16, 2019 · 1 comment
Open

Customer specific prices are cached #1535

onigunn opened this issue Mar 16, 2019 · 1 comment

Comments

@onigunn
Copy link

onigunn commented Mar 16, 2019

Customer specific Product Prices

We got a store with customers all over the world each customer has depending on his billing country different tax rates. So product prices are different if customers are signed in. Currently varnish always delivers the first cached version of a product page.
My first approach was to extend vcl_hash to include a custom cookie, which is set on customer login/logout. I've added following to the default.vcl

sub vcl_hash {

    # default implementation

    if (req.http.Cookie ~ "magento_country=") {
        std.log("hash_data - country cookie: " + regsub(req.http.Cookie, "^.*?magento_country=([^;]*);*.*$", "\1"));
        hash_data(regsub(req.http.Cookie, "^.*?magento_country=([^;]*);*.*$", "\1"));
    } else {
        std.log("no country cookie found, so we fallback to de");
        hash_data("de");
    }

    std.log("vcl_hash end return lookup");
    return (lookup);
}

Varnish still delivers first cached version instead of a different one based on the hash. vcl_log states, that the cookie is detected and added to the hash. Anyone an idea why I don't get another version?

@mabigo
Copy link

mabigo commented Sep 12, 2019

same issue. I tried a different approach, by bypassing cache based on cookie via pass/pipe on top of vcl_recv().

if (req.http.Cookie ~ "pricegroup=") { return (pipe); }

Yet, still the first version/price that was requested is delivered regardless of cookie being set. i also noticed, whenever I clean up the esi cache in admin, I get the correct first response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants