Andrey Khomyakov technical blog
Stop joomla from caching system messages
If you are running joomla 1.5 or 1.7 with caching turned on, you might have seen that sometimes system messages are getting cached and are shown every time you access some page.
It can even happen that users see messages of other users.
Anyway, I came up with a solution for that.
I made it for joomla 1.7, but it should work similar for 1.5.
Here is what you need to do:
- Open /libraries/joomla/application/application.php
- Find getMessageQueue() function
- Add code so function look like this:
public function getMessageQueue()
{
// For empty queue, if messages exists in the session, enqueue them.
if (!count($this->_messageQueue)) {
$session = JFactory::getSession();
$sessionQueue = $session->get('application.queue');
if (count($sessionQueue)) {
$input = new JInput();
$rand_token = $input->get('rand_token');
if(!$rand_token) {
$uri =& JURI::getInstance();
$query = $uri->getQuery(1);
$query['rand_token'] = md5(rand());
$uri->setQuery($query);
$unique_url = $uri->toString( );
header('Location: '.$unique_url);
exit;
}
$this->_messageQueue = $sessionQueue;
$session->set('application.queue', null);
}
}
return $this->_messageQueue;
}
This code is adding rand_token parameter to url every time system message is generated, so it makes url unique and joomla cache will not use it again.
Hope this will help you with your joomla system messages issue.





unfortunately its not working on joomla 1.5
Interesting. I have come across the exact same problem; it’s amazing that this isn’t more widespread, and that such a glaring bug hasn’t been fixed.
My own solution is slightly different. Whether it’s better or not is up for debate, but I believe it’s less intrusive because it changes the cache plugin, rather than application.php, which is slightly ‘deeper’ in the core.
Edit plugins/system/cache.php, find the onAfterRender() function, and after:
add:
This basically stops writing a page to the cache if there are any system messages in the queue.