2

So I noticed that by setting the 'cacheDuration' => false it seems to set, by default, the expiration date to 1 year from when the cache is saved.

I found this in /app/services/TemplateCacheService.php starting from line 263:

if($duration <= 0) 
{
  $duration = 31536000; // 1 year
}

I know a longer duration could be achieved by setting the expiration to something like 4Y. But I wanted to raise this and ask if it was an oversight or what the reason was for setting it to a year and overriding the specific value of not setting an expiration at all...?

Thanks.

3

Yeah, it's slightly awkward.

First off it should be '0', instead of false if you want it to cache indefinitely (documentation bug, just fixed).

It's slightly awkward because the cacheDuration config setting is used for multiple things, but when the TemplateCacheService uses it, it requires an expiration date (not optional).

So if it sees 0, it will just pick one reasonably far out (a year), but you can set it to something higher if you want.

What should probably happen is everywhere that uses the cacheDuration config setting should have its own, separate config setting.

Not going to happen for Craft 2, but make a note to look at it once Craft 3 launches.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.