colinmollenhour / Cm_Cache_Backend_Redis

A Zend_Cache backend for Redis with full support for tags (works great with Magento)
Other
389 stars 142 forks source link

Caching of header -> store_language #123

Closed jg-development closed 6 years ago

jg-development commented 7 years ago

Hi, I have a strange behavior with the redis cache and maybe someone can help. Config etc. is fine, redis is working for session and cache data. I have an theme with normal include of header like:

<?php echo $this->getChildHtml('header') ?>

In this I include the store_language:

<?php echo $this->getChildHtml('store_language') ?>

And the template of the store_language is like this:

<?php if(count($this->getStores())>1): ?>
<div class="form-language">
    <label for="select-language"><?php echo $this->__('Your Language:') ?></label>
    <select id="select-language" title="<?php echo $this->__('Your Language') ?>" onchange="window.location.href=this.value">
    <?php foreach ($this->getStores() as $_lang): ?>
        <?php $_selected = ($_lang->getId() == $this->getCurrentStoreId()) ? ' selected="selected"' : '' ?>
        <option value="<?php echo $_lang->getCurrentUrl(false) ?>"<?php echo $_selected ?>><?php echo $this->escapeHtml($_lang->getName()) ?></option>
    <?php endforeach; ?>
    </select>
</div>
<?php endif; ?>

The Problem is, that the header gets cached over pages. Example: Goto www.example.de/terms -> language switcher url to en = www.example.com/terms goto www.example.de/faq -> language switcher url to en = www.example.com/terms After the first page impression, the header is in the cache and the language url is the "old" one. If I switch to file cache, the problem is gone.

Dies anybody have an idea? Greetings Jan

colinmollenhour commented 7 years ago

Sounds like your cache key info doesn't include the current language. Also make sure the child blocks aren't cached.

On June 7, 2017 4:34:44 PM CDT, Jan Gantzert notifications@github.com wrote:

Hi, I have a strange behavior with the redis cache and maybe someone can help. Config etc. is fine, redis is working for session and cache data. I have an theme with normal include of header like:

<?php echo $this->getChildHtml('header') ?>

In this I include the store_language:

<?php echo $this->getChildHtml('store_language') ?>

And the template of the store_language is like this:

<?php if(count($this->getStores())>1): ?>
<div class="form-language">
<label for="select-language"><?php echo $this->__('Your Language:')
?></label>
<select id="select-language" title="<?php echo $this->__('Your
Language') ?>" onchange="window.location.href=this.value">
   <?php foreach ($this->getStores() as $_lang): ?>
<?php $_selected = ($_lang->getId() == $this->getCurrentStoreId()) ? '
selected="selected"' : '' ?>
<option value="<?php echo $_lang->getCurrentUrl(false) ?>"<?php echo
$_selected ?>><?php echo $this->escapeHtml($_lang->getName())
?></option>
   <?php endforeach; ?>
   </select>
</div>
<?php endif; ?>

The Problem is, that the header gets cached over pages. Example: Goto www.example.de/terms -> language switcher url to en = www.example.com/terms goto www.example.de/faq -> language switcher url to en = www.example.com/terms After the first page impression, the header is in the cache and the language url is the "old" one. If I switch to file cache, the problem is gone.

Dies anybody have an idea? Greetings Jan

-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/colinmollenhour/Cm_Cache_Backend_Redis/issues/123

-- Sent from my Android phone with K-9 Mail. Please excuse my brevity.

jg-development commented 7 years ago

Hi, I will look into that and give you some feedback. The strange thing for me was: It works with file cache. Greetings Jan