Support » Plugin: The SEO Framework » Enabled object cache doesn’t allow to filter robots meta

  • Resolved KittMedia

    (@kittmedia)


    Hi there!

    We’re using The SEO Framework on a bunch of websites with active domain mapping. Thus, we want to allow indexing on the mapped domain but not on the actual domain in WordPress.

    To do that, we have to change the value of the robots meta in the frontend and did it this way:

    /**
     * Set robots to noindex for base URLs for The SEO Framework.
     * 
     * @since	1.5.0
     * @since	1.5.2	Disable on admin for settings default to index
     * @version	1.0.1
     * 
     * @param	array	$meta The meta attributes
     * @return	array The updated meta attributes
     */
    function my_the_seo_framework_robots_meta_array( $meta ) {
    	// do nothing on non-internal domains or in admin
    	if ( ! is_base_url() || is_admin() ) {
    		return $meta;
    	}
    	
    	$meta['noindex'] = 'noindex';
    	$meta['nofollow'] = 'nofollow';
    	
    	return $meta;
    }
    
    add_filter( 'the_seo_framework_robots_meta_array', 'my_the_seo_framework_robots_meta_array' );

    To improve performance, we added object caching to our sites. Unfortunately, this breaks the solution above, since these filters are no more active if object caching and an object cache entry is available. The object cache value usually gets set in the backend, so we cannot change the value for the frontend.

    Thus, I would love to see a filter after the cached value has been received in order to change it according to is_admin.

    As a workaround, I now have to buffer wp_head and change the robots meta string inside it, which is a dirty fix.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Sybre Waaijer

    (@cybr)

    Hello!

    Since you’re trying to render the front-end, doesn’t simply removing is_admin() from the condition do the trick?

    Thread Starter KittMedia

    (@kittmedia)

    Unfortunately, no. If I do so, the default settings in the meta boxes in the backend show noindex and nofollow as default on the base URL.

    Plugin Author Sybre Waaijer

    (@cybr)

    Hello!

    I’m sorry for my delayed response. It took me a while to wrap my head around this.

    I assume you’re utilizing object caching with TSF (SEO Settings > Performance > Object Cache Settings)?

    If you disable that, does everything work as intended without the buffer-hacks? I verged on removing the feature in the last minor patch, anyway, since it doesn’t bring any measurable benefit — especially after the last two major releases were heavily focussed on optimization.

    I also expected issues like these to result from that, but I never got a report. So, now I have all the more reasons to eliminate the feature. I’m interested in reading what you think about the feature-removal!

    Cheers 🙂

    —-

    To affirm my statement regarding performance, I just tested the feature. On PHP 7.2 and 8.0, with and without OpCode caching, TSF’s object caching feature removes about 2 milliseconds of loading time… Considering HTTP, PHP, browser, script, and font-loading overhead, it’s completely negligible. I think I’m going to purge the feature!

    • This reply was modified 2 months ago by Sybre Waaijer. Reason: test results
    • This reply was modified 2 months ago by Sybre Waaijer. Reason: clarity
    Thread Starter KittMedia

    (@kittmedia)

    Hi Sybre!

    I assume you’re utilizing object caching with TSF (SEO Settings > Performance > Object Cache Settings)?

    Yes, correct!

    After I disabled it and use my function from above, it works fine.

    So if there are no performance concerns (I also couldn’t measure any) I think your idea is right to remove it. 🙂

    Plugin Author Sybre Waaijer

    (@cybr)

    Removing it I shall do then 🙂 Cheers!

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.