Sunday, November 4, 2007

Javascript and Cookies for dynamic caching

The problem with whole page caching is that for a given URL, all the content must be the same. For dynamic websites, this is a poor solution. People are used to seeing Hello, Bob and extra menu items if the user has access to more features.

Instead of full page caching, you could do partial page caching but that means more server work and more disk reads. In the previous blog entry, Veneer has a nice full page caching feature so Veneer will work around the problem.

Using a nice javascript cookie library from Paul Stephens, Veneer can parse the fields the cookie fields and adjust the Dom accordingly.

There is another problem. The URLs change depending on which module is being used. Routing in Veneer is /module/action or /controller/module/action. How does the javascript parse the URL? A quick google search produces a url parsing library by Steven Levithan.

Now, if the user is logged in, the name is stored on the client for personalization. The member level is stored on the client so if the client is an admin, a context sensitive admin link is placed in the admin area.

3 comments:

Unknown said...

alvin, I am afraid that I am asking something trivial but could you please let me know how I may url-call the functions in your modules. Thanks e/

Alvin said...

I am not sure I understand what you mean. All of the actions map to URL's.

phil said...

Hi,

I try to use your CMS and I get

Fatal error: Uncaught exception 'Zend_Session_Exception' with message 'Zend_Session::start() - session_start() [function.session-start]: open(/projects/veneercms/veneercms-read-only/sitecache/localhost/sessions/sess_8f81680ad83c8132250a337ca845b533, O_RDWR) failed: No such file or directory (2)' in /Applications/MAMP/bin/php5/lib/php/Zend/Session.php:379 Stack trace: #0 /projects/veneercms/veneercms-read-only/Veneer/Session.php(44): Zend_Session::start() #1 /projects/veneercms/veneercms-read-only/Veneer/Init.php(59): Veneer_Session->__construct() #2 /projects/veneercms/veneercms-read-only/index.php(6): include_once('/projects/venee...') #3 {main} thrown in /Applications/MAMP/bin/php5/lib/php/Zend/Session.php on line 379

I use current version of Zend downloaded and I checkedout your code.
Can you please give me some steps to get it working slightly? I like the idea very much.

cheers, Phil