Ticket #1595 (reopened enhancement)

Opened 3 years ago

Last modified 8 months ago

Post Content Prerendering

Reported by: markjaquith Assigned to: markjaquith
Priority: normal Milestone: 2.9
Component: Optimization Version: 2.1.2
Severity: normal Keywords: 2nd-opinion dev-feedback
Cc:

Description

This is a first effort on building post content prerendering, as was discussed on wp-hackers.

The new hook is "the_content_filtered" and is stored in the already existing post_content_filtered column.

It involves a modification to the wp_insert_post() function that handles the prerendering on post publish/save. Several global variables are called in, so as to "recreate" the environment (the $post object and $id, namely.) This is because some "the_content" filters need to use these values and modify the post content accordingly.

For display, setup_postdata() has been modified. If the post_content_filtered column is blank and the post_content column is NOT, the post_content_filtered data will be filtered right then, and inserted into the database. This eliminates the need to do "rebuilding" as the "rebuilding" is done on the fly.

"the_content" filter will function as before. I have moved WP's default "the_content" filters to "the_content_filtered" and the idea is that when WP 1.6 comes out, we can educate plugin authors about the new hook, so they can make a decision for their plugin (most filters can be run ahead of time, but a few, like Google Hilight, need to be dynamic). The real speed boost will come when users have many plugins installed that use the new hook, especially on the front page, or category/month archives. Think textile2, acronym, multiple search/replace plugins, etc. I'd had this stuff max out PHP's memory when run on the front page! This is going to be much more efficient.

This is a first try, and I did this rather quickly, but it seems to work. Paging is working too, which is good.

Attachments

prerendering__functions.php.diff (1.3 kB) - added by markjaquith on 08/17/05 06:30:55.
for WP 1.6 SVN
prerendering__functions-post.php.diff (3.1 kB) - added by markjaquith on 08/17/05 06:31:00.
for WP 1.6 SVN
prerendering__default-filters.php.diff (1.0 kB) - added by markjaquith on 08/17/05 06:40:28.
for WP 1.6 SVN

Change History

08/17/05 06:30:55 changed by markjaquith

  • attachment prerendering__functions.php.diff added.

for WP 1.6 SVN

08/17/05 06:31:00 changed by markjaquith

  • attachment prerendering__functions-post.php.diff added.

for WP 1.6 SVN

08/17/05 06:40:28 changed by markjaquith

  • attachment prerendering__default-filters.php.diff added.

for WP 1.6 SVN

11/11/05 02:12:05 changed by matt

  • milestone changed from 1.6 to 2.1.

11/19/05 10:59:57 changed by davidhouse

  • keywords changed from bg|2nd-opinion to bg|2nd-opinion bg|has-patch.

11/29/06 22:49:54 changed by matt

  • milestone changed from 2.1 to 2.2.

03/11/07 01:05:45 changed by rob1n

  • keywords deleted.
  • status changed from new to closed.
  • resolution set to wontfix.
  • milestone deleted.

I don't think this is feasible. Filters change by the second, and if you want pre-rendering might as well use something like WP-Cache to pre-render the whole page?

03/11/07 02:12:05 changed by masquerade

  • keywords set to bg|2nd-opinion bg|has-patch.
  • status changed from closed to reopened.
  • version changed from 1.6 to 2.1.2.
  • resolution deleted.
  • milestone set to 2.2.

Filters don't really change by the second. Theoretically, they could I suppose, however most filters, especially the defaults, things like abbr tag plugins, etc. etc. are fairly constant.

Prerendering the post I think is useful for those who don't want to cache the whole page, because it might have other dynamic content on the page, especially in the sidebar. Not having to run the filters on the post each time saves a considerable amount of processor time. It is also possible that, to ease your fears and to make everything better for everyone, that along with the prerendered content, an array of the filters which are applied to it is stored, and when displaying, compare the list of currently applied filters with the ones that are prerendered, and update accordingly.

+1 for this idea.

03/11/07 04:43:11 changed by rob1n

  • keywords changed from bg|2nd-opinion bg|has-patch to 2nd-opinion dev-feedback.

I don't think the current patches apply. Feel free to prove me wrong, though.

03/11/07 11:46:08 changed by westi

For me pre-rendering is a very good idea.

The more code that we can remove from needing to run when a post / page is displayed the better.

+1

03/12/07 09:23:37 changed by markjaquith

My original suggestion was that we keep the_content running live for 100% backwards compat, and implement a new the_content_filtered hook that'll run on the pre-filtered content (i.e. after the_content). That way plugin authors can update at their leisure and once they do, the full speed benefits will be realized.

the other option is making the new hook the "live" option that is run every time. This will break any plugins that need to run live (few do), but it'd give us the maximum immediate speed boost.

We'd also need to make sure that the prerendered content expires whenever plugins are enabled or disabled. We'd want to functionize that so that other plugins could call it. For instance, say you have a plugin activated that alters the_content, and you change an option in that plugin. You'd want the prerendered content to expire so it could be updated.

We might eventually have Manage > Cache with built-in HTML output cache management that would allow you to manually flush the HTML + content prerendering caches.

03/27/07 19:51:49 changed by foolswisdom

  • milestone changed from 2.2 to 2.3.

09/05/07 19:49:07 changed by foolswisdom

  • milestone changed from 2.3 to 2.4 (next).

02/12/08 09:31:45 changed by pishmishy

  • milestone changed from 2.5 to 2.6.

Bumping milestone for feature freeze.