Bug #88178
closed
Page cache is deleted, when an uncached (Extbase) Plugin performs a redirect
Added by Helmut Hummel over 5 years ago.
Updated over 5 years ago.
Description
There is a legitimate case that a plugin performs a redirect (sends Location header).
Usually such plugins are defined as uncached.
Uncached plugins are called, even when the rest of the page remains cached.
With the change applied for #83755 any redirect performed by such plugins, leads to the complete page cache being deleted.
On a side note (and the reason I ran into this), rendering frontend pages on CLI with the goal to warm up the cache is not possible any more after this change,
because http_response_code() always returns false when called from cli SAPI.
My conclusion would be: Any plugin that needs a redirect, should be marked as not cachable.
If there is a valid case for giving cached plugins the possiblity to perform a permanent redirect,
then this redirect should be stored in the cache and be handled right after the cache is retrieved.
- Status changed from New to Under Review
- Related to Bug #83755: Extbase TYPO3\CMS\Extbase\Mvc\Controller\AbstractController->redirectToUri() – remove HTML redirect? added
A usecase, which contradicts this change request.
Consider a cachable show action for a seminar date. This view can be fully cached, it mostly never changes.
In case the seminar date has to be cancelled, the state of the seminar date is changed and the respective cache entry is flushed.
The show action then issues a redirect to an overview page, in case the page for this seminar date is still accessed by someone.
The redirect is so to say permanent, but since the core does not store the HTTP headers with the cache content, this redirect response must not be cached.
Thanks for the use case. There would have been multiple ways to achieve desired behavior without introducing such core change, which seems pretty intrusive to me.
- Using HttpUtility::redirect (or throw new DirectResponseException in 9.5 and higher)
- Disabling the page cache using TSFE->set_no_cache (which is done e.g. in News extension)
- Throw a 404 and handle the 404 accordingly in a custom 404 handler
- Convert the plugin to USER_INT before issuing the redirect
I added the last to Extbase redierctToUri as I don't see a use case for issuing a redirect and at the same time have the same plugin action cached (which only works currently at cost of always rendering the complete page, writing and then again removing the page cache)
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
- Status changed from Resolved to Under Review
- Status changed from Under Review to Resolved
- Status changed from Resolved to Closed
Also available in: Atom
PDF