help needed: what do various cache switches affect

Author Message

Massimiliano Bariola

Thursday 15 December 2005 3:22:29 am

I have run into a cache-related problem with my website.

I use , as cache switches, templatecache, viewcaching, templatecompile. the site works perfectly when those are off.

on the site I have 3 pages, especially homepage ( see http://www.ioscelgo.it ) which have a buggy behavior when caches are on. the buggy part is a poll part.
if an user hasn't voted, he will see the radiobuttons to vote.

The fact that an user has voted will be recorded on a cookie, and if he is a registered user, also on DB. to do that, I have written an extension to save the cookie and eventually the DB entry, and a custom template operator which checks in cookies and db if he did vote.

the logic goes like this...
{if $current_poll|uservoted} -- uservoted is my own template operator
.... display results ......
{else}
.... display radiobuttons and form; ACTION is /extension/mypollhandler
{/if}

The trouble is, when I turn on caching, this mechanism will no longer work
and every user - also those who haven't voted - will see the results and will be unable to vote. It is as the cache evaluates the fact that an user has voted, and all following page requests from different users will be sered the "already voted" part.
I had a similar problem (which I still have to resolve) when using paginator (the google.tpl) - the first user visiting a page including google.tpl will make it evaluate a certain set of links to pages 1,2,3 ... of object set A, and those links will also be used by paginators of objects sets B , resulting in user going from, say, page 1 of set A to page 2 of set B.

I think this is due to the fact that caching of that part of page is not related to publishing of an object, as it is not an object in itself, but rather an evaluation of many factors which implicitly use node info etc, and then produce an output.

I have tried surrounding the parts with a {cache-block $current_user, $uri_string} as suggested by the docs, but this caused the template output to show both the results AND the radiobuttons.

I am currently running the site with cache disabled, but of course this makes a big hit on the server. Anyone can help? either by spotting an error in my "code" or suggesting how to set up cache configs? I have trouble understanding exactly what viewcaching does (does it still output php? does it output html so there is no more condition evaluated dynamically? etc.)

thank you

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.