georgringer / news_filter

Filter news
Other
4 stars 12 forks source link

Caching issue when list view is initially called without filter #12

Open mmunz opened 1 year ago

mmunz commented 1 year ago

In ext_localconf.php the list action is added to the list of non-cachable actions only when a search POST var is set:

$vars = \TYPO3\CMS\Core\Utility\GeneralUtility::_POST('tx_news_pi1');
if (isset($vars['search']) && is_array($vars['search'])) {
    $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions']['News']['plugins']['Pi1']['controllers'][\GeorgRinger\News\Controller\NewsController::class]['nonCacheableActions'][] = 'list';
}

Because ext_localconf.php is only called once and then cached this leads to caching issues, when the list page with filters is initially called without any filter, because the list action is not added to the list of uncachable actions and filters do not work.

mmunz commented 1 year ago

Unfortunately i currently have no idea how to properly fix this, but if Georg or someone else has any suggestions i could try to fix it and create an PR.

klodeckl commented 1 year ago

Same here. It is not the best solution but I fixed it with the following typoscript:

// Disable caching if search params set [traverse(request.getParsedBody(), 'tx_news_pi1/search/fromDate') || traverse(request.getParsedBody(), 'tx_news_pi1/search/toDate') || traverse(request.getParsedBody(), 'tx_news_pi1/search/filteredCategories')] temp.news < tt_content.list.20.news_pi1 tt_content.list.20.news_pi1 > tt_content.list.20.news_pi1 = COA_INT tt_content.list.20.news_pi1.10 < temp.news [global]

klodeckl commented 2 months ago

My solution also doesn’t work now, I don’t know why and why it has worked some time ago. When setting

[traverse(request.getParsedBody(), 'tx_news_pi1/search/subject') || traverse(request.getParsedBody(), 'tx_news_pi1/search/fromDate') || traverse(request.getParsedBody(), 'tx_news_pi1/search/toDate') || traverse(request.getParsedBody(), 'tx_news_pi1/search/filteredCategories')] temp.news < tt_content.list.20.news_pi1 tt_content.list.20.news_pi1 > tt_content.list.20.news_pi1 = COA_INT tt_content.list.20.news_pi1.10 < temp.news config.no_cache = 1 [global]

then it works (only with config.no_cache = 1 and COA_INT didn’t solve it).

A proper solution for this would be great.