Make WordPress Core


Ignore:
Timestamp:
07/30/2025 11:01:58 PM (10 months ago)
Author:
peterwilsoncc
Message:

Feeds: Cache RSS feeds in global transients.

Moves the caching of RSS feeds requested via fetch_feed() from single site transients (get|set|delete_transient()) to global transients (get|set|delete_site_transient()).

On multisite installs of WordPress, this replaces per site caching with the global multisite cache to allow a single cache to be shared between all sites. This reduces the amount of data stored in the database and improves performance of feeds when multiple sites are ingesting the same URL.

Props rollybueno, spacedmonkey, peterwilsoncc.
Fixes #63719.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/feed/fetchFeed.php

    r60490 r60524  
    5959
    6060    /**
     61     * Ensure that fetch_feed uses the global cache on Multisite.
     62     *
     63     * @ticket 63719
     64     *
     65     * @group feed
     66     * @group ms-required
     67     *
     68     * @covers ::fetch_feed
     69     * @covers WP_Feed_Cache_Transient
     70     */
     71    public function test_fetch_feed_uses_global_cache() {
     72        $second_blog_id = self::factory()->blog->create();
     73
     74        $filter = new MockAction();
     75        add_filter( 'pre_http_request', array( $filter, 'filter' ) );
     76
     77        fetch_feed( 'https://wordpress.org/news/feed/' );
     78
     79        switch_to_blog( $second_blog_id );
     80
     81        fetch_feed( 'https://wordpress.org/news/feed/' );
     82        $this->assertEquals( 1, $filter->get_call_count(), 'The feed cache should be global.' );
     83    }
     84
     85    /**
    6186     * Mock response for `fetch_feed()`.
    6287     *
Note: See TracChangeset for help on using the changeset viewer.