making bbPress (and WordPress) work better!

Is there a way to “DEFER” PHP code until after content is served?

So I’ve been thinking in weird ways about how WordPress and PHP works in general and why on a typical page the mysql queries may only take a quarter second but the rest of the PHP can take a half second or more…

Why can’t PHP/Wordpress defer some of the code execution until the HTML content is sent to the visitor? Are PHP sessions tied to the visitor being connected? Could WordPress have some kind of “post /html” queue where updates to databases and other stats are generated AFTER the visitor is sent what they requested?

Most of this idea is out of ignorance in how PHP works and how to identify parts of WordPress that could benefit from such a technique. I know you can use ob_flush to force any content waiting to be sent. But that’s useless if WordPress doesn’t have anything to do afterwards.

Javascript sort of has this method using DEFER in the script tag which I take advantage often (it causes the external script not to be loaded/executed until /body finishes (not all browsers support it).

So in WordPress there is alot of little stuff that can’t wait until a pseudo-cron job and has to be done on a per-visitor basis, but not necessarily while they are waiting.

This whole idea requires more investigation/research but I think it has potential?
Any ideas from the php “pros” ?

One response

  1. It would involve a somewhat major overhaul of the general logic, but what about instead of hooking all that stuff directly to the page that’s being displayed, you instead just hook a javascript HttpRequest on the actual display page, which then calls the script that actually does all the logging and routine stuff a few seconds after the user’s page is displayed, all behind the scenes.

    September 18, 2006 at 3:23 pm

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s