Monday, August 3, 2009

Re: View caching - multiple domains (L10n)

I will explain my workaround to solve similar problem. My website is
compatible with multiple languages. Language value is store in a
cookie, when cache is enabled the views only shows in one language. To
solve this, I modify core to add a prefix at the name of cached views
(app/tmp/cache/views/), prefix would be the language name (stored in
cookie).

--FILE: html/cake/dispatcher.php
-- --FUNCTION: cached
This function read cached file when cache is enabled. Filename of
cached view is stores in variable $path. I added this code to add a
language prefix to filename.

$path = strtolower(Inflector::slug($path));
// hack
App::import('Component', 'Cookie');
$cookie = new CookieComponent();
$cookie->key = Configure::read('Security.salt');
$lang = $cookie->read('lang');
$path = $lang . '_'. $path;

--FILE: html/cake/libs/views/helper/cache.php
-- --FUNCTION: __writeFile
This function write cached view to file when is enabled. I added
language prefix to filename.

$cache = strtolower(Inflector::slug($path));
// hack
App::import('Component', 'Cookie');
$cookie = new CookieComponent();
$cookie->key = Configure::read('Security.salt');
$lang = $cookie->read('lang');
$cache = $lang . '_' .$cache . '.php';

Regards,
Shaddow

On 14 jul, 22:39, "3lancer.eu" <kilc...@gmail.com> wrote:
> Hello,
>
> I'm building an app where language versions will be set using
> subdomains (en.app.tld, de.app.tld etc). Therefore I'd like to hear
> from any of you who have experience with Cake view caching in such a
> case. As far as I see the filenames in app/tmp/cache/views are built
> using url only, so should I expect any conflicts? Will view caching be
> any use or wanton waste of resources?
>
> Any suggestions appreciated.
>
> Regards,
> Piotr

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: