Making WordPress.org


Ignore:
Timestamp:
07/10/2025 04:22:42 AM (16 months ago)
Author:
dd32
Message:

Plugin Directory: Lower the cache time (dramatically) for the browse=updated and browse=new endpoints.

See ​https://wordpress.slack.com/archives/C1LBM36LC/p1752075478561369?thread_ts=1749072442.873339&cid=C1LBM36LC

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/standalone/class-plugins-info-api.php

    r13620 r14484  
    240240                        } else {
    241241                                $response = $response->data;
    242                                 wp_cache_set( $cache_key, $response, self::CACHE_GROUP, self::CACHE_EXPIRY );
     242                                wp_cache_set( $cache_key, $response, self::CACHE_GROUP, $this->query_plugins_cache_duration( $request ) );
    243243                        }
    244244                }
    … …  
    287287
    288288        /**
     289         * Returns the cache duration for a Query Plugins request.
     290         *
     291         * @param Plugins_Info_API_Request $request The request object.
     292         * @return int The cache duration in seconds.
     293         */
     294        protected function query_plugins_cache_duration( $request ) {
     295                // New / Updated plugins get a much shorter cache duration.
     296                if ( in_array( $request->browse, array( 'new', 'updated' ) ) ) {
     297                        return 900; // 15 minutes.
     298                }
     299
     300                // Defaults to 6 hours otherwise.
     301                return self::CACHE_EXPIRY;
     302        }
     303
     304        /**
    289305         * API Endpoint for the 'popular_tags' and 'hot_tags' API endpoints.
    290306         */
Note: See TracChangeset for help on using the changeset viewer.