• Resolved jornalosaopaulo

    (@jornalosaopaulo)


    Hello there,

    I’ve been reviewing the cache invalidation logic in Cache_Invalidation_Hooks.php (get_post_related_links()), and noticed that when a post is published, updated, or deleted, the plugin purges the taxonomy term link, but does not also purge the corresponding feed URL.

    For comparison, the code does explicitly purge:

    • get_author_feed_link() for the post author
    • get_post_type_archive_feed_link() for the post type archive

    But there’s no equivalent added for taxonomy term feeds.

    My use case: I have a setup where one site fetches a tag feed from another site every minute via RSS. This feed is currently excluded from caching entirely, which causes frequent DB queries and occasional timeouts under load. I’d like to cache this feed, but only if it gets purged automatically when a relevant post is published/updated – otherwise it would serve stale content indefinitely (since the cache never expires by TTL in our config).

    Questions:

    1. Is this an intentional omission, or an oversight?
    2. Is there a recommended way to extend the purge list to include taxonomy term feed URLs?
    3. Would this be considered for inclusion in the default purge list in a future release?

    Thanks!

Viewing 1 replies (of 1 total)
  • Plugin Support Poonam Namdev

    (@poonam9)

    Hi @jornalosaopaulo,

    Thanks for the detailed report. The plugin already purges the feed URLs for author archives and post type archives whenever a post changes, but it’s missing the same step for taxonomy term archives (tags, categories, custom taxonomies). That’s an oversight rather than a deliberate decision, and it’s something we’d treat as a bug fix.

    In the meantime, you can work around it using the swcfpc_post_related_url_init filter, which lets you inject additional URLs into the purge list whenever a post is published, updated, or deleted. Add something like this to your theme’s functions.php or a small mu-plugin:

    add_filter( 'swcfpc_post_related_url_init', function( $urls, $post_id ) {
        foreach ( get_object_taxonomies( get_post_type( $post_id ) ) as $taxonomy ) {
            $terms = get_the_terms( $post_id, $taxonomy );
            if ( empty( $terms ) || is_wp_error( $terms ) ) continue;
            foreach ( $terms as $term ) {
                $feed = get_term_feed_link( $term->term_id, $term->taxonomy );
                if ( $feed && ! is_wp_error( $feed ) ) $urls[] = $feed;
            }
        }
        return $urls;
    }, 10, 2 );

    This will automatically purge the feed URL for every taxonomy term associated with the post — tags, categories, and any custom taxonomies on every publish, update, or delete.

    We can’t promise a specific timeline for when the fix will be included in the plugin, but we have forwarded the issue to our team.

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.