{"id":12989453,"date":"2020-06-15T19:48:52","date_gmt":"2020-06-15T19:48:52","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/yoast-saving-post-preview-info-in-object-cache\/"},"modified":"2020-06-15T19:58:36","modified_gmt":"2020-06-15T19:58:36","slug":"yoast-saving-post-preview-info-in-object-cache","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/yoast-saving-post-preview-info-in-object-cache\/","title":{"rendered":"Yoast saving post preview info in Object Cache"},"content":{"rendered":"<p>Hi there, <\/p>\n<p>This bug started after upgrading to Yoast ~14.2. I&#8217;m currently using v14.3.<\/p>\n<p>When an author is editing a post and then clicks in &#8220;preview&#8221;, Yoast saves all the meta information in the object cache. That includes: canonical url, post thumbnail (saves the default image), Breadcrumb, etc.<\/p>\n<p>Then when the post is published, this information isn&#8217;t flushed immediately. The canonical stays wrong (?p=312123) and the image thumbs for twitter, google and facebook is the default.<\/p>\n<p>To flush this infos, i need to wait a few minutes and then update the post.<\/p>\n<p>I&#8217;m using a Redis Object Cache from Pressjitsu, but the problem is not specific to this opt-in. I&#8217;ve already tried to change it to other two WP Redis, and the problem persists. In fact, with this other plugins, even more information is saved, as the breadcrumbs.<\/p>\n<p>Is there a way to stop Yoast from caching stuff when it&#8217;s from a post preview URL? I believe that this could fix the error.<\/p>\n<p>I&#8217;ve tried removing Yoast header stuff using this code, but it doesn&#8217;t fix the problem, since the information is already cached when &#8220;template_redirect&#8221; is beeing called:<\/p>\n<pre><code>add_action( &#039;template_redirect&#039;, &#039;remove_yoast_postpreview&#039; );\nfunction remove_yoast_postpreview() {\n    if ( is_user_logged_in() &amp;&amp; is_preview() ) {\n        $front_end = YoastSEO()-&gt;classes-&gt;get( Yoast\\WP\\SEO\\Integrations\\Front_End_Integration::class );\n\n        remove_action( &#039;wpseo_head&#039;, [ $front_end, &#039;present_head&#039; ], -9999 );\n    }\n}<\/code><\/pre>\n<p>Maybe there&#8217;s a way to stop Yoast from the &#8220;init&#8221; action, when the request is from a post preview?<\/p>\n<p>Any thoughts?<\/p>\n","protected":false},"template":"","class_list":["post-12989453","topic","type-topic","status-publish","hentry","topic-tag-redis","topic-tag-yoast"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/12989453","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":1,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/12989453\/revisions"}],"predecessor-version":[{"id":12989496,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/12989453\/revisions\/12989496"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=12989453"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}