Extension, Module

Archived
Forum
(read-only)

CE Cache

ExpressionEngine 2, ExpressionEngine 3

Back to this add-on's main page
View Other Add-ons From Causing Effect

     

CE Cache and Multi-Language

Support (Resolved)

codeM
codeM

Great add-on love the performance boosts it gives our customer’s website. One thing that was kind of a challenge for us was using CE Cache with a MultiLanguage addon such as Biber Multi-Language (or other that basically work the same) which uses htaccess files to re-write the /en/ and /fr/ urls and use use simple plugins to fetch the correct field from ou channel entry such as body_fr or body_en.

Running CE-Cache, since the URLs where being re-written it seems that for CE-Cache the url example.com/fr/page and example/en/page are being seen as the same page when in reality their content uses the correct body_en or body_fr fields when being parsed. We then end up with mixed language pages depending on what various embeds was cached first

What I did as a temporary solution was to add to the CE_Cache_utils.php file right before the cache path was returned, we appended the current language from a global var used in the Biber extension :

$site =  $site."/".$EE->config->_global_vars['language']

so now the file driver cache structure is not only site specific but also language specific:
ce_cache
|—sitename
  |—french
      |—local etc..
  |—english
      |—local etc…

Let me know if there is a more elegant way of doing this without hacking the add-on. Because for example now in the CP we can’t use the view CE-Cache items for obvious reasons, without hacking that as well…

Fred Carlsen
# 1
Fred Carlsen

Thanks for the hack, it works quite well so far!

Aaron / CE: Could you add support for this, or show us a possible better way of handling this?

codeM
# 2
codeM

No problem:-)
The only thing is quite annoying for client is cache busting by tag or otherwise doesn’t work or memchae-memchached either

I’d have to find a way to hack it as well but i would much rather get some feedback from Aaron on this first?

Fred Carlsen
# 3
Fred Carlsen

I agree.

Did you fix the PHP error you get when accessing the CP? See https://skitch.com/fredink/88g5q/apc-items-expressionengine

codeM
# 4
codeM

Sorry, I dont get that error.
and I dont use APC…

it says undefined variable : language_code on line 28… I have no language_code variable, just the EE config language which in my case is set by MultiLanguage add-on by Biber

Fred Carlsen
# 5
Fred Carlsen

Ah, you’re right. I use a separate index.php in a folder called /en and set the global variable there. Thought Biber worked the same way.

Causing Effect - Aaron Waldon
# 6
Developer
Causing Effect - Aaron Waldon

Hi codeM and Fred!

CE Cache will automatically use the current URL. So if there is a language segment in the URL, that should be automatically handled *unless* the Biber add-on you’re using is altering the EE URI string that is used to get the URL. If it is messing with the EE URI string though, developers usually leave a global variable behind with the original URI string. Please take a look in the module for how a similar workaround is handled in the CE Cache module for Zoo Visitor support (same for Freebie support that is coming in the next release too).

Basically, if the correct URI is used, it is a better situation, because then the CE Cache control panel interface will work as expected too! I hope that makes sense. :) Please let me know if you have any questions.

codeM
# 7
codeM

Thanks Aaron, yeap looked at the code for Zoo and did the same add-on specific adjustment

Line 539 $url "/".$this->EE->config->_global_vars[ 'language_code' ]."/".$this->EE->uri->uri_string(); 

Cache works perfect, now just have have to see if busting and memcached works with this but I expect they will just fine.

Okan Esen
# 8
Okan Esen

Information: In the latest version (1.9) $url must be replaced with $this->cache_url.

Polygon
# 9
Polygon

Hi. I use the bieber MLE Addon as well. Where do I have to alter the string in CE_Cache_utils.php (1.10.1)?

Causing Effect - Aaron Waldon
# 10
Developer
Causing Effect - Aaron Waldon

Hi Polygon!

This thread is over 2 years old. I think you can now use the following config setting to add a URL prefix (if that’s what you’re wanting to do):

/*
| The url_prefix= is prepended to the cache item URL, even if the url is
| overridden via url_override=. This setting can be useful for sub-directory
| EE installations, and multi-language MSM sites, because EE does not include
| the folder path to the index.php directory in it's internal URL.
*/
$config['ce_cache_url_prefix'''

 

Polygon
# 11
Polygon

So easy. Thank you :)