tractorcow / silverstripe-dynamiccache

Simple on the fly caching of dynamic content for Silverstripe
39 stars 27 forks source link

Disable cache after X minutes #46

Closed Firesphere closed 1 year ago

Firesphere commented 8 years ago

I would like to cache my homepage, but have the cache dismissed after 2 minutes. Is that possible?

jonom commented 8 years ago

cacheDuration config setting should take care of it? That would be site wide though, not just on the home page.

tractorcow commented 8 years ago

Ah, sorry, you're right... the lifetime is global. =(

You could set a custom lifetime on save (maybe another cache header?) but it would have to be a PR.

jonom commented 7 years ago

@Firesphere could you do something like this?

class HomePageCacheCustomisation extends DynamicCacheExtension
{
    public function updateCacheKeyFragments(array &$fragments) {
        // Include current time in 2 minute brackets
        $fragments[] = floor(time() / 60 * 2);
    }
}

Could cause some garbage to pile up in your cache but might do the trick?

dhensby commented 6 years ago

got a solution? time to close?