[wp-trac] [WordPress Trac] #32264: wp_enqueue_media() is slow on large sites
WordPress Trac
noreply at wordpress.org
Thu Jul 23 14:25:18 UTC 2015
#32264: wp_enqueue_media() is slow on large sites
-------------------------------------------------+-------------------------
Reporter: philipjohn | Owner: rhurling
Type: enhancement | Status: assigned
Priority: normal | Milestone: Awaiting
Component: Posts, Post Types | Review
Severity: normal | Version: 3.9
Keywords: good-first-bug has-patch needs- | Resolution:
testing | Focuses:
| performance
-------------------------------------------------+-------------------------
Comment (by mboynes):
On 32264.6.patch:
1. There is some repeated code. I would recommend making a function to
purge the media cache, which takes a post ID, and hooking into
`add_attachment` and `delete_attachment`. This becomes a little more
challenging when considering the next two notes...
2. It's only necessary to delete the `has_audio`, `has_video` transients
on `add_attachment` if the transient value is 0. For a site that adds a
lot of audio or video, this can be a noticeable performance improvement,
since that query would only have to be run the first time, and then only
after an audio or video file is deleted.
3. It's only necessary to delete the `has_audio`, `has_video` transients
on `delete_attachment` if the transient value is 1.
4. It's only necessary to delete the `media_months` transient on
`add_attachment` if the month and year of the attachment are not already
included in the transient. Furthermore, if they aren't included, we could
just add them to the transient instead of deleting it and forcing that
query to run again.
@philipjohn: I'm happy to make these changes if you don't have time.
In general, I'm in favor of these being transients over using the object
cache. I don't see a reason to run these queries on every single pageload
of the new/edit post screen, regardless of the site's size or object cache
preference.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/32264#comment:16>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list