I am trying to run a piece of code on every page load. I have the following
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd"> <event name="controller_action_predispatch"> <observer name="csp" instance="MyVendor\MyModule\Observers\MyObserver" shared="false" disabled="false" /> </event> </config>
This works besides from when Full Page Cache is enabled. When it is enabled my observer does not run.
Is there a better event I should watch to enable me to run code on every page load regardless of if Full Page Cache is turned on or off?