In SS4, the previously documented way of changing the partial cache lifetime no longer works
SS_Cache::set_cache_lifetime('cacheblock', 60 * 60 * 24 * 7);
Does anyone have any clue how to increase the lifetime now?
In SS4, the previously documented way of changing the partial cache lifetime no longer works
SS_Cache::set_cache_lifetime('cacheblock', 60 * 60 * 24 * 7);
Does anyone have any clue how to increase the lifetime now?
The correct answer is to create a new config file in the app/_config directory. I called mine cache.yml. Then you need to specify a priority so that it doesnât get stomped on by the SilverStripe config that it is meant to override in the first place e.g the âAfterâ priority in the config header:
---
Name: appcache
After: '*#corecache'
---
SilverStripe\Core\Injector\Injector:
Psr\SimpleCache\CacheInterface.cacheblock:
constructor:
defaultLifetime: 604800
Try:
SilverStripe\Core\Injector\Injector:
Psr\SimpleCache\CacheInterface.cacheblock:
constructor:
defaultLifetime: 604800 # 7 days
From https://docs.silverstripe.org/en/4/developer_guides/performance/caching/#invalidation
Hi JonoM,
Thank you for your suggestion.
I have tried that before and it didnât have any effect on the partial cache lifetime (still refreshes after 10min)
I am currently accessing the cache via:
<% cached 'sidenav', $List('SilverStripe\CMS\Model\SiteTree').max('LastEdited'), $List('SilverStripe\CMS\Model\SiteTree').count() %>
<% loop $Menu(1) %>
...
<% end_loop %>
<% end_cached %>
I tried that and it does not work for me. The lifetime is still 10 minutes. Does it require any other configuration? I just created the new file cache.yml and copied your code.
EDIT: Ok, it looks like it doesn´t work only on localhost, it seems to work fine on production server.
I ran into this as well, couldnât find it documented anywhere (or see any code for itâŚ) so thanks for sharing.
For me, works fine with SS_ENVIRONMENT_TYPE=âliveâ on localhost