If you are not opposed to languages ββlocated at different URLs, Turpentine can handle this for you: https://github.com/nexcess/magento-turpentine/issues/36
If you want them to behave like they do out of the box, keep going.
You need to change the way you create varnish in VCL Link: https://www.varnish-cache.org/trac/wiki/VCLExampleCachingLoggedInUsers
, cookie , Magento . ( : http://demo.magentocommerce.com) , , Varnish cookie , , ,
- cookie, URL- :
sub vcl_hash {
hash_data(req.url);
hash_data(req.http.host);
if (req.http.Cookie ~ "(?:^|;\s*)(?:store=(.*?))(?:;|$)"){
hash_data(regsub(req.http.Cookie, "(?:^|;\s*)(?:store=(.*?))(?:;|$)"));
}
return (hash);
}
, , VCL cookie
- cookie , X-Mage-Lang:
sub vcl_fetch {
if (req.http.Cookie ~ "(?:^|;\s*)(?:store=(.*?))(?:;|$)"){
if (!beresp.http.Vary) {
set beresp.http.Vary = "X-Mage-Lang";
} elseif (beresp.http.Vary !~ "X-Mage-Lang") {
set beresp.http.Vary = beresp.http.Vary + ", X-Mage-Lang";
}
}
set beresp.http.X-Mage-Lang = regsub(req.http.Cookie, "(?:^|;\s*)(?:store=(.*?))(?:;|$)");
}
: https://github.com/varnish/varnish-devicedetect/blob/master/INSTALL.rst
Mage_Core_Model_App, cookie "store". Magento CE 1.7 _checkCookieStore:
protected function _checkCookieStore($type)
{
if (!$this->getCookie()->get()) {
return $this;
}
$store = $this->getCookie()->get(Mage_Core_Model_Store::COOKIE_NAME);
if ($store && isset($this->_stores[$store])
&& $this->_stores[$store]->getId()
&& $this->_stores[$store]->getIsActive()) {
if ($type == 'website'
&& $this->_stores[$store]->getWebsiteId() == $this->_stores[$this->_currentStore]->getWebsiteId()) {
$this->_currentStore = $store;
}
if ($type == 'group'
&& $this->_stores[$store]->getGroupId() == $this->_stores[$this->_currentStore]->getGroupId()) {
$this->_currentStore = $store;
}
if ($type == 'store') {
$this->_currentStore = $store;
}
}
return $this;
}
$_SERVER ['X-Mage-Lang'] cookie