I m facing an issue with cache, i have a function in my theme onPageProcessed that insert open graph in head the vars come from my modular blueprints, all working ok with no cache
this is excerpt of my function
— php
public function onPageProcessed(Event $e)
{
$page = $e[‘page’];
$header = $page->header();
$metadata = $page->metadata();
$uri = $this->grav[‘uri’]->path();
$route = $page->route();
sorry to bump old thread. I’m still having that issue with the cache, each time i save the page the metadatas are injected with onPageProcessed. Hope someone can put me on the right track
i try onPageInitialized instead of onPageProcessed and inside onPageInitialized function i call a private function with all my meta stuff, it seems to work
Only recently I began to understand how to work with dynamic content and have caching enabled. The reason why your previous method using onPageProcessed didn’t work and using onPageInitialized does, is explained in Caching and Events.
The downside of using onPageInitialized is that the code in it is run on every page request. I’m curious why other pages loose their metadata when one page is saved? Do you clear the full cache somewhere?