Adding base64 encoded referrer URL to Esi request URL's

I have added an encoded referrer param to the Esi request URL on blocks that have the 'page' scope. I have also changed a line the Esi controller that creates a dummy request based on the referrer URL - it now uses the native Magnento controller method to get the referrer URL:

$this->_getRefererUrl();

This picks up the encoded URL param if it's present and uses it in the dummy request. If there is no URL param then it uses the HTTP_REFERER from the $_SERVER array, which is what your code was using previously.

I have tested this and it seems to solve the issue of the language selector using the URL of the last page rather than the current page.

The drawback to this is it adds a few additional chars to the URL but it's a small increase.

I hope this is useful for you.

Jon