Q:

TYPO3 search box does not work after page is cached

There is a Problem with the Caching in TYPO3.
I have a simple search box that calls the itemRepository to get some items based on the search term. If no term is given, all Items are listed.
This works only for the first time.
After I hit the search button, the search term is cached and will always be used even if I enter a new search term.
The first term is always shown in the searchbox and used for the search. I have to clear the cache to make it work again. 
Even when i put var_dump($terms); somwhere it generates an output for one time.
I know I could disable the cache for listAction, but this would make the page very slow since there are many items listed by default.
Is there a solution for this? Using TYPO3 8.7.8.
<!-- Searchbox -->
<f:form name="list" action="list" enctype="multipart/form-data">
    <f:form.textfield name="terms" value="{terms}" placeholder="{f:translate(key:'enter_searchterm')}"/>
    <button><f:translate key="search"/></button>
</f:form>

<!-- list with found items -->
<f:for each="{items}" as="item">

    ...
    ...

    <li>{item.title}</li>

    ...
    ...

</f:for>

/**
* @param string $terms
*/
public function listAction($terms = "") {
    $items = $this->itemRepository->findBySearch($terms);

    $this->view->assign('items', $items);
    $this->view->assign('terms', $terms);
}

A:

You should indeed set the list()-action with a search term parameter to non-cacheable.
To keep the performance for the non-filtered list you can add another non-cached action (without any parameters).
This way you can keep the performance on the non-filtered list.

