多语言Magento商店如何与清漆工作。 清漆中是否有可用的配置,所以我们可以在Cookie上创建缓存基础?Magento多语言商店与清漆
回答
如果你不介意的语言处于不同的URL,松节油可以处理这个要求:https://github.com/nexcess/magento-turpentine/issues/36
如果你希望它们表现为他们开箱即用,让我们继续前进。
您必须修改清漆如何产生在你的VCL 参考:https://www.varnish-cache.org/trac/wiki/VCLExampleCachingLoggedInUsers
我们要修改这个也考虑到基于语言选择的Magento套店里的cookie。 (下面的行为在这里:http://demo.magentocommerce.com)很不幸,这得到棘手清漆往往当它看到的cookies会基于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来改变任意头部的缓存,我们称之为X-Mage-L昂:
sub vcl_fetch {
#can do this better with regex
if (req.http.Cookie ~ "(?:^|;\s*)(?:store=(.*?))(?:;|$)"){
if (!beresp.http.Vary) { # no Vary at all
set beresp.http.Vary = "X-Mage-Lang";
} elseif (beresp.http.Vary !~ "X-Mage-Lang") { # add to existing Vary
set beresp.http.Vary = beresp.http.Vary + ", X-Mage-Lang";
}
}
# comment this out if you don't want the client to know your classification
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此标题。在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-郎'],而不是饼干
添加继光油配置线,
if(beresp.http.Set-Cookie) {
return (hit_for_pass);
}
什么是这些线路的影响目前店?这是最好的还是最短的答案? ;) – fbtb 2015-03-03 17:13:22
- 1. 维护多语言商店
- 2. Magento多商店视图 - 语言切换问题
- 3. 多商店和多品牌与magento
- 4. Magento;派遣多商店
- 5. Magento多商店SSL分享
- 6. magento多个商店视图
- 7. Magento多语言
- 8. Magento多货币w /多个商店
- 9. magento商店视图
- 10. 多语言商店 - 动态更改自定义菜单的语言
- 11. Magento多个商店 - 父母/子女
- 12. 设置envif主机Magento多个商店
- 13. Magento - 使用多选和商店视图
- 14. Magento的多商店网站问题
- 15. 在多个Magento商店中使用BlueSnap
- 16. MAMP本地瓦特/多个Magento商店
- 17. Azman与多家商店
- 18. Magento商店ID在cronjob
- 19. Magento的商店 - 通过
- 20. 获取magento商店列表
- 21. Magento的商店 - SQL错误
- 22. Magento的商店 - 扩展
- 23. Magento:在商店代码Dash
- 24. Magento 2:如何获得当前的商店视图代码语言?
- 25. 清漆
- 26. Magento多语言 - 在语言中的双重变化结果在404(或如何更改商店内的语言而不是视图)
- 27. 如何创建父Magento商店,其中有多个商店根据它与不同的域
- 28. Magento:使用变量在CMS语法中构建商店URL
- 29. Magento语言切换
- 30. 创建多语言网站在magento
使用cookie解决方案缓存只适用于一个用户。 – 2013-07-05 06:59:00
这不是一个会话cookie,它触发了其中有语言的cookie的值 – timbroder 2013-07-08 15:26:59
好吧,我的错误。很好的概述。 – 2013-07-09 07:15:12