I'm looking to set different response headers for different pages. I have tried with controller_front_send_response_before. The problem is getFullAction method returned the value (cms_index_index) correctly at the first time of load. For the second time, it returned triple underscore (___). It returns the correct value when FPC in disabled mode.

Observer instance:


namespace Vendor\Module\Observer\Frontend\Controller;

use Magento\Framework\App\Request\Http as HttpRequest;

class FrontSendResponseBefore implements \Magento\Framework\Event\ObserverInterface
    private $request;

    public function __construct(
        HttpRequest $request
        $this->request = $request;

    public function execute(
        \Magento\Framework\Event\Observer $observer
    ) {        
        $fullActionName = $this->request->getFullActionName();

The observer itself has request and response params.


// This event gives possibility to launch something before sending output (allow cookie setting)
$eventParams = ['request' => $this->_request, 'response' => $this->_response];
$this->_eventManager->dispatch('controller_front_send_response_before', $eventParams);

I have tried the below method as well in the above observer instance but no luck.

$request = $observer->getData('request');

Any idea about how to solve this issue?



Check my answer to a similar problem (the event observed was different, but the logic should be the same as in your case) - getFullActionName() returns empty results for product pages inside predispatch observer, maybe it helps you.

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.