Publisher is EE6 compatible, but it does not support the Fluid field. Please do not contact asking when support will be available.

If you purchased an add-on from expressionengine.com, be sure to visit boldminded.com/claim to add the license to your account here on boldminded.com.

Ticket: Changing TTL to “0” sets static cache items to expire in 5 seconds

Status Resolved
Add-on / Version Speedy 1.6.0
Severity
EE Version 7.1.6 PRO

University Communications

Nov 16, 2022

When I change the speedy_ttl value to “0” in the config settings, the expiration time for static cache items is set to 5 seconds (see screenshot). The expected behavior is the cache items should not expire until cache is broken, correct?

This was set in config.php:
$config[‘speedy_ttl’] = “0”;

Thank you!

#1

BoldMinded (Brian)

Nov 17, 2022

For static caching if the TTL is less than 5 seconds it defaults to 5 seconds because of potential redirect loops. All other drivers do accept a 0 value, but not static (I should update the docs, sorry about that). If you need long TTL for static cache you’ll have to give it a high number. You could try this…

Update line 297 of the StaticDriver.php to this:

if ($ttl !== 0 && $ttl < 5) {
                $ttl = 5;
            }
#2

BoldMinded (Brian)

Nov 17, 2022

Or just don’t set the TTL…

#3

University Communications

Nov 17, 2022

Thanks, I tried making the code change to StaticDriver.php but it didn’t have any effect. It still sets expires at to 5 seconds.
If I don’t set the TTL at all, then it defaults to 1 hour.

#4

BoldMinded (Brian)

Nov 18, 2022

On line 293 of that file change the conditional to this instead:

if ($ttl === false || $ttl === 0) {
#5

University Communications

Nov 21, 2022

Great, changing that conditional worked. Cache items show expiration as infinite now.
Note though that setting TTL to “0” with quotes doesn’t work. Needs to be without quotes around the 0 because of strict equality operator in the conditional:

$config[‘speedy_ttl’] = 0;

Thank you!

#6

BoldMinded (Brian)

Nov 21, 2022

I changed it to a falsey check…

if (!$ttl) {
#7

BoldMinded (Brian)

Nov 21, 2022

Actually, this is a better change.

if ($ttl === false || (is_numeric($ttl) && (int) $ttl === 0)) {


You could also just set $config[‘speedy_ttl’] = false; too and it would have worked.

Login to reply