joomla/joomla-platform — Issue #675: en masse head element caching is causing unnecessary code
Author: drewgg
Created: 2011-12-27 04:37:02+00:00
State: open

I originally brought up this issue on the forums here (gives a description of the issue with some of the files/classes involved): http://forum.joomla.org/viewtopic.php?p=2696622

I was asked to post my finding to an already opened ticket on the CMS tracker here (I posted steps there to reproduce the issue): http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_id=8103&tracker_item_id=27503

There it was suggested that the issue is in the platform and that I should open a ticket here.

Brief Description:
Modules are caching head data unrelated to that module.

More details:

When a module is cached (via JModuleHelper::moduleCache()) JCache::setWorkarounds() will retrieve 10 types of head data from JDocumentHTML (via JDocumentHTML::getHeadData())

JCache will unset 5 of the data types:

JDocumentHTML->title
JDocumentHTML->description
JDocumentHTML->link
JDocumentHTML->_links
JDocumentHTML->_metaTags

and cache the remaining 5 with the module:

JDocumentHTML->_styleSheets
JDocumentHTML->_style
JDocumentHTML->_scripts
JDocumentHTML->_script
JDocumentHTML->_custom

Often most or all of that remaining head data being cached has nothing to do with the module being cached (eg, mod_breadcrumbs may store custom head data added by a Content Plugin). This results in unnecessary code being added to the head which can cause bugs. This isn't noticeable right away because the head data is dedupped at some point, so a script file (for example) being cached in multiple module caches will still only be seen once in the final html source. However, unneeded scrips/styles/etc and data unique to specific pages will start to show up where they don't belong.

Thanks for reading!