octobercms/october · error · Twig\Error\SyntaxError
Unknown "%s" configuration.
Error message
Unknown "%s" configuration.
What it means
The {% cache %} tag parses one key expression followed by optional modifiers, and the only supported modifier name is ttl. While parsing, any other NAME token after the key throws this Twig SyntaxError at compile time - e.g. an attempt to configure expiry with a different word (expire, timeout, time, seconds).
Source
Thrown at modules/cms/twig/tokenparser/CacheTokenParser.php:29
/**
* CacheTokenParser
*/
class CacheTokenParser extends AbstractTokenParser
{
/**
* Parses a token and returns a node.
* @return PartialNode
*/
public function parse(Token $token): Node
{
$stream = $this->parser->getStream();
$key = $this->parser->parseExpression();
$ttl = null;
while ($stream->test(Token::NAME_TYPE)) {
$k = $stream->getCurrent()->getValue();
if (!in_array($k, ['ttl'], true)) {
throw new SyntaxError(sprintf('Unknown "%s" configuration.', $k), $stream->getCurrent()->getLine(), $stream->getSourceContext());
}
$stream->next();
$stream->expect(Token::OPERATOR_TYPE, '(');
$line = $stream->getCurrent()->getLine();
if ($stream->test(Token::PUNCTUATION_TYPE, ')')) {
throw new SyntaxError(sprintf('The "%s" modifier takes exactly one argument (0 given).', $k), $line, $stream->getSourceContext());
}
$arg = $this->parser->parseExpression();
if ($stream->test(Token::PUNCTUATION_TYPE, ',')) {
throw new SyntaxError(sprintf('The "%s" modifier takes exactly one argument (2 given).', $k), $line, $stream->getSourceContext());
}
$stream->expect(Token::PUNCTUATION_TYPE, ')');
if ($k === 'ttl') {
$ttl = $arg;
}View on GitHub (pinned to b608633a7e)
Solutions
- Remove the unknown modifier - ttl is the only one this tag accepts.
- Spell the modifier exactly ttl: {% cache 'sidebar' ttl(3600) %} (minutes).
- Move any other behaviour (key namespacing, invalidation) into the key expression or application code.
Example fix
{# before #}
{% cache 'sidebar' ttl(3600) timeout(60) %}
{# after: ttl is the only supported modifier #}
{% cache 'sidebar' ttl(3600) %} Defensive patterns
Strategy: validation
Validate before calling
// Lint a CMS template body before saving/deploying it
use Twig\Source;
$env = app('twig.environment'); // the CMS Twig instance with October's tags
try {
$env->parse($env->tokenize(new Source($templateBody, $fileName)));
} catch (\Twig\Error\SyntaxError $e) {
// reject the save: message includes the unknown modifier and line
} Try / catch
try {
echo twig_render($template);
} catch (\Twig\Error\SyntaxError $e) {
// compile-time failure: report $e->getMessage() with line, fix the tag
} Prevention
- Remember {% cache key ttl(n) %} supports exactly one modifier: ttl.
- Lint templates through Twig's parser in CI before deploy.
- When copying tags from docs, match them against the version you run.
When it happens
Trigger: Writing {% cache 'sidebar' timeout(60) %} or {% cache 'key' ttl(3600) seconds(30) %} - any modifier token whose value is not 'ttl' hits the in_array($k, ['ttl']) rejection during template compilation.
Common situations: Developers guessing modifier names from other cache APIs; copy-pasting tags from tutorials targeting different CMS versions; adding unsupported options like scope or tags to the tag.
Related errors
- The "%s" modifier takes exactly one argument (0 given).
- The "%s" modifier takes exactly one argument (2 given).
- Invalid syntax in the component tag. Line %s
- Invalid syntax in the content tag. Line %s
- Invalid syntax in the framework tag. Line %s
AI-assisted analysis of octobercms/october@b608633a7e (2026-08-21).
Data as JSON: /api/errors/21339fb1ec2368f2.
Report an issue: GitHub.