huguesalary / Magento-Varnish

This Magento extension provides a Real Full Page Caching for Magento powered by Varnish with support of Session-Based information caching (Cart, Customer Accounts, ...) via ESI includes
Other
95 stars 18 forks source link

[Fix] Caching mechanism doesn't take store-specific URL into consideration #10

Closed kdckrs closed 7 years ago

kdckrs commented 12 years ago

When you have a Magento setup as below where each store has it's own URL:

http://domain.com/nl/ http://domain.com/fr/ http://domain.com/en/

Something goes wrong when a certain block is cached it caches it without the nl, fr or en suffix. This results in a bad block being shown when you switch language/store.

Example:

You visit http://domain.com/nl/ and cache the header (It is being cached as /varnish/cache/getBlock/... without the nl up front)

When you then switch to http://domain.com/fr/ it will still show the cached version of the header that was built in the /nl/ version.

This can be solved by editing the /Betabrand/Varnish/Model/Observer.php file:

Line 136:

$src->setUrl("varnish/cache/getBlock/cachetype/{$src->getCacheType()}/expiry/{$src->getExpiry()}/fingerprint/{$this->_hash()}");

replace by:

$src->setUrl(Mage::getBaseUrl() . "varnish/cache/getBlock/cachetype/{$src->getCacheType()}/expiry/{$src->getExpiry()}/fingerprint/{$this->_hash()}");

This fix will make it work ;)