Increasing partial cache lifetime


#1

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?


#2

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


#3

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 %>