diff --git a/libraries/src/Document/HtmlDocument.php b/libraries/src/Document/HtmlDocument.php
index f0683501674d8..50531488e8565 100644
--- a/libraries/src/Document/HtmlDocument.php
+++ b/libraries/src/Document/HtmlDocument.php
@@ -11,6 +11,7 @@
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Cache\Cache;
+use Joomla\CMS\Factory;
use Joomla\CMS\Helper\ModuleHelper;
use Joomla\CMS\Log\Log;
use Joomla\CMS\Uri\Uri;
@@ -471,8 +472,19 @@ public function getBuffer($type = null, $name = null, $attribs = array())
if ($this->_caching == true && $type == 'modules' && $name !== 'debug')
{
- $cache = \JFactory::getCache('com_modules', '');
- $hash = md5(serialize(array($name, $attribs, null, get_class($renderer))));
+ $cache = Factory::getCache('com_modules', '');
+ $itemId = (int) Factory::getApplication()->input->get('Itemid', 0, 'int');
+
+ $hash = md5(
+ serialize(
+ array(
+ $name,
+ $attribs,
+ \get_class($renderer),
+ $itemId
+ )
+ )
+ );
$cbuffer = $cache->get('cbuffer_' . $type);
if (isset($cbuffer[$hash]))