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.

eZ debug

Timing: Jan 20 2025 20:04:39
Script start
Timing: Jan 20 2025 20:04:39
Module start 'layout'
Timing: Jan 20 2025 20:04:39
Module start 'content'
Timing: Jan 20 2025 20:04:39
Module end 'content'
Timing: Jan 20 2025 20:04:39
Script end

Main resources:

Total runtime0.0129 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0041 588.0469151.2266
Module start 'layout' 0.00410.0019 739.273436.6953
Module start 'content' 0.00600.0056 775.968890.1875
Module end 'content' 0.01160.0014 866.156329.9922
Script end 0.0129  896.1484 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002116.2724140.0002
Check MTime0.00107.3542140.0001
Mysql Total
Database connection0.00053.839210.0005
Mysqli_queries0.002217.283830.0007
Looping result0.00000.070010.0000
Template Total0.00118.210.0011
Template load0.00086.543610.0008
Template processing0.00021.659910.0002
Override
Cache load0.00064.775110.0006
General
dbfile0.001612.650680.0002
String conversion0.00000.046140.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs