Make WordPress Core

Opened 14 months ago

Last modified 14 months ago

#58286 new defect (bug)

Growing database due to unnecessary transients containing "g_url_details_response_"

Reported by: davidki's profile davidki Owned by:
Milestone: Awaiting Review Priority: normal
Severity: critical Version: 6.2
Component: Database Keywords:
Focuses: Cc:

Description (last modified by SergeyBiryukov)

I created 2 external links in the block editor. This created 2 different transients in the database in wp_options, that have a different dynamic part at the end:


This transient contains "g_url_details_response_" and is produced by file class-wp-rest-url-details-controller.php

The value of such created transient is entire html from URL to which I link.

I only want to add some external link in gutenberg editor. Why on earth is necessary to parse the entire html from URL to which I link?

What if I will have for example 20 external affiliate links on one page and I will have 1000 such pages.

This will unnecessarily bloat the database with useless and unnecessary data!

How can I prevent the creation of transients whose name part contains "g_url_details_response_"?

I tryed it using this filter:

apply_filters( "pre_set_site_transient_{$transient}", mixed $value, string $transient ) 

But it needs full transient name, which is created dynamically using this function

private function build_cache_key_for_url( $url ) {
	return 'g_url_details_response_' . md5( $url );

from file class-wp-rest-url-details-controller.php

So please remove these pointless transients from wordpress or give users a way to prevent them from being created!

Thank you for any reply,


Change History (2)

#1 @SergeyBiryukov
14 months ago

  • Description modified (diff)

#2 @petitphp
14 months ago

Hello @davidki

When clicking on links in the editor, Gutenberg will attempt to display a preview of for external links (page title + primary image or favicon).

The rest controller you mentioned will make a request to the remote URL to load the first hundred bytes and retrieve the @head@ tag to extract the relevant information. To speed up the process and avoid spamming the remote servers, each response will be cached in a transient for one hour.

At first glance, it doesn't seem to be a way of disabling the preview mechanism in the editor. You can open an issue in the Gutenberg repository to propose that enhancement.

As for the transients, they should be cleaned automatically every day after they expired.

Note: See TracTickets for help on using tickets.