Increasing attribute type number but it reset itself and don't know why

Hi Concreters :slight_smile:

i made a little peace of code to count the number of view for some pages. i had create a number attribute and write this

<?php
$page_count = $c->getAttribute('page_count');
if (!$cp->canAdminPage()) { //update only if not connected as editor
    $c->setAttribute('page_count', $page_count + 1);
}
echo $page_count;
?>

it works, each page displaying increase the number but i don’t know why it’s reseting alone sometimes.

is someone know why or have a better solution to do this ?
i had using attributes because it’s a good and simple way to catch the number in page list block for exemple.

see you :slight_smile:

Try turning off the ‘Block Cache’ in System & Settings → Optimisation.

i’ll try, but i’m not shure to understand why the block cache would reseting the number of my attribute to zero.