{"action":"created","issue":{"url":"https://api.github.com/repos/nexcess/magento-turpentine/issues/381","labels_url":"https://api.github.com/repos/nexcess/magento-turpentine/issues/381/labels{/name}","comments_url":"https://api.github.com/repos/nexcess/magento-turpentine/issues/381/comments","events_url":"https://api.github.com/repos/nexcess/magento-turpentine/issues/381/events","html_url":"https://github.com/nexcess/magento-turpentine/issues/381","id":23440825,"number":381,"title":"Dummy request from referrer affects current URL in cached blocks","user":{"login":"jonnnnyw","id":5824499,"avatar_url":"https://avatars.githubusercontent.com/u/5824499?v=3","gravatar_id":"","url":"https://api.github.com/users/jonnnnyw","html_url":"https://github.com/jonnnnyw","followers_url":"https://api.github.com/users/jonnnnyw/followers","following_url":"https://api.github.com/users/jonnnnyw/following{/other_user}","gists_url":"https://api.github.com/users/jonnnnyw/gists{/gist_id}","starred_url":"https://api.github.com/users/jonnnnyw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonnnnyw/subscriptions","organizations_url":"https://api.github.com/users/jonnnnyw/orgs","repos_url":"https://api.github.com/users/jonnnnyw/repos","events_url":"https://api.github.com/users/jonnnnyw/events{/privacy}","received_events_url":"https://api.github.com/users/jonnnnyw/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2013-11-28T10:13:46Z","updated_at":"2015-10-28T09:10:44Z","closed_at":"2014-03-11T19:13:08Z","body":"Hi,\r\n\r\nI have a problem related to getting the current URL, from the request object, in cached blocks that are loaded through the ESI controller.\r\n\r\nIn the getBlockAction in the ESI controller you have the following code @line 72:\r\n\r\n```php\r\nif( $referer = Mage::helper( 'core/http' )->getHttpReferer() ) {\r\n    $dummyRequest = Mage::helper( 'turpentine/esi' )\r\n        ->getDummyRequest( $referer );\r\n}\r\n```\r\n\r\nThis creates a dummy request block based on the referrer. The problem with this is that when you try and get the current URL from the request object, it is always the referring URL or your dummy request URL (checkout/cart).\r\n\r\nAn example of where this happens is in the language switcher template. This gets the current URL from the Store object, which generates the language switch URL from the request. This causes the language switcher to always take you back to the last page you visited or to the checkout/cart page.\r\n\r\nCould it be possible to populate the session with the current URL before the cache blocks are loaded and then use that to create the dummy request? Alternatively, maybe you could send an encoded referrer param in the Esi request, similar to what Magento does for it's login redirects.\r\n\r\nOtherwise this module is working flawlessly and has massively increased the speed of our application. Keep up the great work."},"comment":{"url":"https://api.github.com/repos/nexcess/magento-turpentine/issues/comments/151774728","html_url":"https://github.com/nexcess/magento-turpentine/issues/381#issuecomment-151774728","issue_url":"https://api.github.com/repos/nexcess/magento-turpentine/issues/381","id":151774728,"user":{"login":"data-digger","id":1395675,"avatar_url":"https://avatars.githubusercontent.com/u/1395675?v=3","gravatar_id":"","url":"https://api.github.com/users/data-digger","html_url":"https://github.com/data-digger","followers_url":"https://api.github.com/users/data-digger/followers","following_url":"https://api.github.com/users/data-digger/following{/other_user}","gists_url":"https://api.github.com/users/data-digger/gists{/gist_id}","starred_url":"https://api.github.com/users/data-digger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/data-digger/subscriptions","organizations_url":"https://api.github.com/users/data-digger/orgs","repos_url":"https://api.github.com/users/data-digger/repos","events_url":"https://api.github.com/users/data-digger/events{/privacy}","received_events_url":"https://api.github.com/users/data-digger/received_events","type":"User","site_admin":false},"created_at":"2015-10-28T09:10:44Z","updated_at":"2015-10-28T09:10:44Z","body":"This seems to be a bug? Consider following request flow from user:\r\n`[1]` http://www.mystore.com/category/?filter_by=price\r\n`[2]` http://www.mystore.com/category/\r\n\r\nWhile fetching `[2]` Turpentine would use `[1]` as current URL.\r\n\r\n```\r\n# Nexcessnet_Turpentine_EsiController::getBlockAction(), line ~92\r\n\r\n                if( $referer = $this->_getRefererUrl() ) {\r\n                    $referer = htmlspecialchars_decode( $referer );\r\n                    $dummyRequest = Mage::helper( 'turpentine/esi' )\r\n                        ->getDummyRequest( $referer );\r\n                } else {\r\n```\r\n\r\nHowever on direct hit to `[1]` (without http referer set) Turpentine would use different URL (in my case it seems to be http://www.mystore.com/). As some blocks rely on request parameters the same call may produce different results even though \"raw\" call (i.e. without Varnish & Turpentine) does'n depend neither on Cookie nor Referer.\r\n\r\nShouldn't Turpentine use `[2]` as current URL for dummy request?"}}