多語言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. 單語言Magento商店 - 多語言WordPress的博客
- 2. 維護多語言商店
- 3. Magento刪除記住商店語言
- 4. Magento多商店視圖 - 語言切換問題
- 5. Magento Magmi:多個商店/語言的屬性導入
- 6. 多商店和多品牌與magento
- 7. magento多個商店視圖
- 8. Magento多商店SSL分享
- 9. Magento;派遣多商店
- 10. Magento多語言
- 11. 語言商店特定網址上的Magento 404錯誤
- 12. 如何在magento的topmenu中顯示商店語言?
- 13. Magento商店URL
- 14. Magento的孔PUCH清漆
- 15. Magento多貨幣w /多個商店
- 16. Magento:刪除多商店(網站)和清理數據庫
- 17. magento商店視圖
- 18. 多語言商店 - 動態更改自定義菜單的語言
- 19. Magento多個商店模板更改
- 20. 設置envif主機Magento多個商店
- 21. Magento的 - 修改搜索多個商店
- 22. Magento多個商店 - 父母/子女
- 23. 在多個Magento商店中使用BlueSnap
- 24. magento商店的多個網址?
- 25. MAMP本地瓦特/多個Magento商店
- 26. Magento - 使用多選和商店視圖
- 27. 多商店設置Magento最大?
- 28. Magento的多商店網站問題
- 29. 產品導入與商店經理Magento
- 30. 多語言+ Multistore Magento配置
使用cookie解決方案緩存只適用於一個用戶。 – 2013-07-05 06:59:00
這不是一個會話cookie,它觸發了其中有語言的cookie的值 – timbroder 2013-07-08 15:26:59
好吧,我的錯誤。很好的概述。 – 2013-07-09 07:15:12