Programmatically expiring pages from cache
Permalink
Hi. I know I can use Cache::set or Cache::get to cache my own objects. But is there a way to force the eviction of a page from the C5 cache ?
The use case would be that the user approves page B. I catch the event. I know that page A depends on some attributes of page B and that it isn't up to date anymore, so I would like to evict page A from cache - like a Cache::delete, but I don't know arguments I would need.
I know I could use a short duration cache, but updates will occur only a few times a week, so I would like to avoid degrading performances.
Any idea if this is possible ?
The use case would be that the user approves page B. I catch the event. I know that page A depends on some attributes of page B and that it isn't up to date anymore, so I would like to evict page A from cache - like a Cache::delete, but I don't know arguments I would need.
I know I could use a short duration cache, but updates will occur only a few times a week, so I would like to avoid degrading performances.
Any idea if this is possible ?
That simple ! :) Thank you, I'm still trying to get around the documentation from Concrete5 and still missing stuff like this...
hi
if i make this in a controller
i've this error :
Cannot call abstract method Concrete\Core\Cache\Page\PageCache::purge()
i need to purge cache of some page programmatically
if i make this in a controller
<?php namespace Application\Controller\SinglePage; use PageCache; use Page; use PageController; class Purge extends PageController { public function view(){ $page = Page::getByID(171); //die(view); PageCache::purge($page); } }
i've this error :
Cannot call abstract method Concrete\Core\Cache\Page\PageCache::purge()
i need to purge cache of some page programmatically
Can you try :
$currentPage = Page::getCurrentPage(); $cache = PageCache::getLibrary(); $cache->purge($currentPage);
thanks!
this work great!
this work great!
hi
How can i check if the page is on cache?
Thanks
How can i check if the page is on cache?
Thanks
hi
i've found a little problem, with full cache page, if i use this:
don't clear the cache of content block, i need to use flush() but this clear the cache of all pages.
For solve the problem i use this :
but clear the cache for all the block of this type.
any ideas for clear only the cache of the block in this page?
i'm tryng with Concrete\Core\Block\Block
refreshBlockOutputCache( )
refreshCache( )
refreshCacheAll( )
i've found a little problem, with full cache page, if i use this:
$currentPage = Page::getCurrentPage(); $cache = PageCache::getLibrary(); $cache->purge($currentPage);
don't clear the cache of content block, i need to use flush() but this clear the cache of all pages.
For solve the problem i use this :
$pageblock = $page_c5->getBlocks('Main'); foreach ($pageblock as $bi) { $block_id = $bi->getBlockTypeID(); $Block = BlockType::getByID($block_id); $Block ->clearCache(); }
but clear the cache for all the block of this type.
any ideas for clear only the cache of the block in this page?
i'm tryng with Concrete\Core\Block\Block
refreshBlockOutputCache( )
refreshCache( )
refreshCacheAll( )
Passing in a page ($c) will purge that page from the cache.