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

  1. Remove the unknown modifier - ttl is the only one this tag accepts.
  2. Spell the modifier exactly ttl: {% cache 'sidebar' ttl(3600) %} (minutes).
  3. 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

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


AI-assisted analysis of octobercms/october@b608633a7e (2026-08-21). Data as JSON: /api/errors/21339fb1ec2368f2. Report an issue: GitHub.