503 Errors in Typo3 with tt_news (And friends)

Saturday, December 2nd, 2006 at 2206

Typo3 is an amazing creation. It’s a fantastically powerful CMS, based on PHP and available for free. However, it’s so powerful that when things go wrong there are many places to look…

I have no idea if this has been resolved in the latest codebase for Typo3, but in the version I was using for a recent project I was being driven crazy by google claiming it couldn’t see my site due to a 503 server response.

Turns out wGet on Ubuntu couldn’t either.

Turns out, that if you have a dynamic content extension like tt_news set to not cache, and happen to insert that via TypoScript into your page, Typo3 will constantly issue temporary 503 headers as it believes the page isn’t cached and is busily being cached, which of course it isn’t because you told it not to.

This causes some irritation when your main page is issuing invisible 503’s (As hey, your site loads in the browser…) but oddly doesn’t feature on Google because their poor robot brain doesn’t know what’s happening.

The fix? Well I trawled the net and found a few bug reports on the issue but the resolution wasn’t visible in the code I had on-server, so I applied a few of them manually. One worked, and he is as follows:

Look for the file class.tslib\_fe.php in path-to-source/typo3/sysext/cms/tslib/ and open her up. Somewhere around line 2574 (Whoever thought 4000 lines in a PHP class was a good thing was clearly smoking something very interesting…) you should see the following code:

// Storing for cache:
if (!$this->no_cache) {
$this->realPageCacheContent();
} elseif ($this->tempContent) { // If there happens to be temporary content in the cache and the cache was not cleared due to new content put in it... ($this->no_cache=0)
$this->clearPageCacheContent();
}

Simply add a line in the 2nd clause, to make it look like so:

// Storing for cache:
if (!$this->no_cache) {
$this->realPageCacheContent();
} elseif ($this->tempContent) { // If there happens to be temporary content in the cache and the cache was not cleared due to new content put in it... ($this->no_cache=0)
$this->clearPageCacheContent();
$this->tempContent = false;
}

And you’re all set. No more mysterious 503’s on genuinely dynamic content.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>