The current:
[caches]
[caches.getjson]
dir = ":cacheDir"
maxAge = -1
[caches.getcsv]
dir = ":cacheDir"
maxAge = -1
[caches.images]
dir = ":resourceDir/_gen"
maxAge = -1
[caches.assets]
dir = ":resourceDir/_gen"
maxAge = -1
-1 means forever. I guess we should establish a good baseline for this before it's too late ...
Note that the motivation for cache expire in the above is different:
The current value is noted in seconds, but I would be happy to change that to something bigger if that makes sense.
Suggest value(s) for the above?
@moorereason @regisphilibert @onedrawingperday and gang
Never mind, the "cleanup logic" will not work without some additional logic, so close this.
Suggest value(s) for the above?
The current value is noted in seconds, but I would be happy to change that to something bigger if that makes sense.
Is there another issue where this conversation could be continued?
Is there another issue where this conversation could be continued?
Not that I know about. Thinking about it, seconds is kind of easy to reason about in unit tests (at least faster). A little harder to express in years ... 31536000. But it's not hard.
Reopen this in relation to #5439 -- I'm going to move the "cleaning routine" to the new file cache (hugo --gc) and with that the defaults above will have more meaning, even for the JSON/CSV case.
Having dealt with DNS TTLs a ton over the years, I much prefer time.Duration for config options instead of using seconds.
maxAge = "10m"
time.Duration is a int64, so -1 would be supported.
fmt.Printf("%v\n", time.Duration(-1)) // Prints -1ns
if time.Duration(-1) < 0 {
// this works
}
if time.Now().Sub(timestamp) > maxAge {
// something like this
}
鈽濓笍 Yes, seconds can be made readable with inline compute (10 * 24 *60 * 60), but as it won't be available in Hugo config files, I agree with @moorereason for something both easily readable and writable like 10m, 12h, 5d etc...
Suggest value(s) for the above?
getJSON and getCSV:
I'd suggest keeping it that way (-1) so current setups are not impacted.
Most helpful comment
Having dealt with DNS TTLs a ton over the years, I much prefer
time.Durationfor config options instead of using seconds.time.Durationis aint64, so-1would be supported.