Typo3 Caching and TypoScript conditions

Reading Time: < 1 minute

Having taken over a somewhat shabby Typo3 project recently (I prefer using the term “challenge” here), digging through the many TypoScript files revealed something which is probably very common in many Typo3 setups:

[code]
[browser = msie]
page.includeCSS.file22 = fileadmin/templates/css/ie.css
[browser = msie] AND [version = 7]
page.includeCSS.file23 = fileadmin/templates/css/ie7.css
[GLOBAL]
[/code]

Why is that a problem? Well, when it comes to caching, Typo3 starts building up Cache entries for every possible condition. So from the above example, we will get 3 cache entries:

  1. Internet Explorer 7
  2. Other Internet Explorers
  3. All other browsers except Internet Explorer

Of course this blows up the database, but space wasn’t the main problem in our case – it was the time it took to rebuild the cache after clearing it. This Typo3 installation serves thousands of pages, and they are crawled regularly to build up the cache, so we really don’t want to waste any time.

So what do we do? First and obvious step, drop IE 7 support! Ahhh, that feels so right…. Ok. Now the remaining, really few IE hacks in the ie.css will be included by using good old Conditional comments:

[code]
page.headerData.123 = TEXT
page.headerData.123.value (
<!–[if IE]>
<script type="text/css" src="fileadmin/templates/css/ie.css"></script>
<![endif]–>
)
[/code]

The additional load for IE users is minimal, and we got rid of quite some cache entries and saved a good amount of computational power.

Leave a Reply

Your email address will not be published. Required fields are marked *

I accept the Privacy Policy

This site uses Akismet to reduce spam. Learn how your comment data is processed.