我应该怎么做才能避免Joomla的缓存缓存这个PHP脚本?

I have this script

<?php   
$db = JFactory::getDBO();
if(!$db)
{
    echo "";
}
elseif(!$htmlVideoDetails->id)
{
    echo "";
}
else
{
    $query = "UPDATE __hdflv_upload SET times_viewed=1+times_viewed WHERE id={$htmlVideoDetails->id}";
    $db->setQuery($query);
    if(!$db->query())
    {
        echo "";
    }
    else
    {
        echo "";
    }
}

?>

With joomla's cache disabled this script works well. But with joomla's script enabled this script stop working.

This probably because joomla's cache save page in html. I checked a cached file, and there isn't any reference to this script.

What should I do for make this script working even in an HTML converted page, or make a reference to this script? I need this script running even in cached (html) version... thank you

Use Ajax. Please check this guide: http://www.itoctopus.com/hit-tracking-not-working-when-joomlas-caching-is-enabled-how-to-solve on how to do this (the guide is made for hit tracking on Joomla, but you can easily switch the query to update hits for your components).