Why is cacheDuration 14 days?
Closed this issue · 2 comments
I'm submitting a...
- bug report
- feature request
- general question
After auto-generating a lot of images, which I started 14 days ago I was shocked today when the dev server started to crash. After some time and a bit of luck, I realized that Imager-x began to recreate all the transforms. After more research, I discovered that the default cacheDuration is set to 1209600.
I don't really get this. Why should we force to create new transforms after 14 days? The transforms are created when the images are uploaded, and I don't see a reason why this cache shouldn't be endless. What is the downside of an endless cache?
Why anything is the way it is in an eight year old plugin, is a good question. It was there in the very first public commit for Imager, and haven't really been up for debate since.
As to why I chose such a short cache duration back then, I can only speculate. Back then, Imager had none of the automatic ways of invalidating existing transforms that it has today. The necessary events in Craft wasn't there, and I hadn't yet nailed the directory structure that makes that possible today. So the reasoning was probably that "assets can change, we don't know when, how or why – it's probably a good idea that they are refreshed occasionally". 14 days probably sounded like a reasonable amount of seconds.
And cacheDuration
was always possible to configure to whatever you wanted, which I assume most users do.
But I agree, in 2023, it's probably better to assume that most people want the created transforms to hang around indefinitely, and the scenarios where you'd want to have the transforms refreshed, are the edge cases. So for the next release I've changed the default value of cacheDuration
to false
, which means they will never expire.
4.2.0 is out, with this change.