0

I use a module which create a route with a non cacheable block in his layout. The page is not cached, like described in http://devdocs.magento.com/guides/v2.1/extension-dev-guide/cache/page-caching/public-content.html

But on some conditions the module made a forward('defaultNoRoute'), then the cms 404 page layout is loaded and the page cached, then every next request gets the 404 cached page !!

try to add this before the forward

$page = $this->pageFactory->create();
//We are using HTTP headers to control various page caches (varnish, fastly, built-in php cache)
$page->setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0', true);

but it load the entire layout before forward, it can cause some troubles, i don't find it very clean ...

Is there any other suggestion to avoid page cache 404 forward ?

0

I ended up to create a plugin on the isCacheable() method of Magento\Framework\View\Layout

In this plugin i check a variable in the registry i setup just before the forward to defaultNoRoute

Sounds more clean to me.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.