Author Topic: Is skinning incompatible with caching using vLib?  (Read 2051 times)

0 Members and 1 Guest are viewing this topic.

Restless

  • Guest
Is skinning incompatible with caching using vLib?
on: Thu, 22. August 2002 - 20:16:17
I am working on a site that is skinnable for each user, i.e., Alice and Bob can both go to http://mysite/content/ and depending on which skin they have chosen, they get different styles, graphics, layouts, colors, what have you.

Of course, if caching is turned on then I'm assuming that it will only be cached for one skin and if the lifetime for the cache hasn't run out, then the wrong skin may be displayed (Bob may see Alice's skin choice, or vice versa).

I know there are caching solutions where I can cache only certain parts of the page, such as a given query or a column on a 'blog, for instance, or I could write the page such that portions write out snippets that are rewritten when they are updated (such that the sidebar, or RSS content as it's retrieved from another site).

However, I'd like a more transparent caching solution.  Does vLibTemplateCache only work per-URL, or does it also incorporate post, cookie and/or session variable values?


Thanks,
Restless

releasedj

  • Guest
Is skinning incompatible with caching using vLib?
Reply #1 on: Thu, 22. August 2002 - 22:36:38
Hi restless,

prior to vLIB 3.0.6 the caching worked on a URL basis, i.e., there would be 1 cache file for index.php and another for contact.php, this was not very maintainable and not the best way of caching.

Therefore, since version 3.0.6 (the current version), the caching works on a per template basis, i.e., theres 1 cached file for index.tmpl, another for header.tmpl ...etc.

So given that vlibTemplate caches on a per template basis, skins are supported; template skins/skin1/index.tmpl would have a different cache to skins/skin2/index.tmpl. You just have to change the instantiation of the class to make sure you include the correct skin, i.e.
Code: [Select]
......
switch skin {
 � �case skin1
 � � � �skin_path = /home/www/skins/skin1/;
 � �break;
 � �case skin2
 � � � �skin_path = /home/www/skins/skin2/;
 � �break;
 � �default
 � � � �skin_path = /home/www/skins/default/;
}

include_once ../vLIB/vlibTemplate.php;

tmpl = new vlibTemplateCacheskin_path.template_file.tmpl;
......

I hope this helps,

Kelvin

NB: Remember that this will only work with vLIB 3.0.6 and above
Last Edit: Thu, 17. February 2005 - 15:04:53 by ClausVB