Summary: What should exclude a page from being cached
Created: 2012-01-24 18:08
Status: Closed, fixed for 2.2.59
Category: Bug
From: CarlosAB
Priority: 1
Version: 2.2.36
OS: openbsd/apache 1.x/php 5.3

Description: I was using a conditional inside a page to show a user his input to himself as part of a lesson on html forms.

The thing is that on the first input 'page?user=Lola', the first condition is executed and will never change again.

Is there a way to exclude a page from cache with a directive? (FastCache does this)

When the page has to be dynamic and process user input, I believe cache should be turned off, right?!

How can this be solved with cache on and conditional working as expected?

I'm using page cache, recipe httpvariables.php and conditional markup, like this:

(:input form action='Formulários#resultado' method='get':)
Nome: (:input text name='user' :)
(:input submit value='Enviar':)
(:input end:)

(:if equal "{$?user}" "":)
%color='red' font-size='30px'%Nenhum valor foi passado%%
%color='green' font-size='30px'%{$?user}%%

Answering my own question... At least it gets documented.

if(count($_GET)>1)  $EnableHTMLCache = 0;
if(count($_POST)>0)  $EnableHTMLCache = 0;

A believe the right answer here would be:

if(count($_GET)>1)  $NoHTMLCache = 1;
if(count($_POST)>0)  $NoHTMLCache = 1;

Looking at the code in cache.php:

if ($NoHTMLCache 
    || !@$PageCacheDir
    || count($_POST) > 0
    || count($_GET) > 2
    || (count($_GET) == 1 && !@$_GET['n'])) { $NoHTMLCache |= 1; return; }

Why count($_GET) has to be bigger than 2 to turn off cache, why not bigger than one as 'n' is always present (not in the first page ) and no other one is set when you are just browsing a page.

Sorry, I'm quite overbooked for another 10 days, I'll try to reply ASAP. --Petko February 03, 2012, at 11:23 AM

No worries...CarlosAB February 04, 2012, at 11:55 PM

After I could experience the bug (impossible to reorder PITS listings), it should be fixed for 2.2.59. Indeed, it should disable the cache if count($_GET)>1, not >2. --Petko January 03, 2014, at 04:46 PM