Skip to content

Customer specific prices are cached #1535

@onigunn

Description

@onigunn

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions