To o-b or not to o-b (output-buffering in WordPress) – UPDATED

(Note: See “Output-Buffering and Extensible WordPress Plug-Ins” for an update to the below that substantially revises my conclusions.)

I asked the following question at Stackoverflow today: “PHP output buffering: When/whether to use for different kinds of real existing sites and applications?

So far, I’ve gotten one answer tending to confirm my general inclination not to use it for the kinds of scripts in which I’m interested.

The following is the full text of my “question”:

Working mainly in WordPress contexts, I have mostly done without output buffering in my PHP code, but I have recently begun to experiment with it and try to discern simply as a user whether there was any noticeable performance impact in typical (for me) scenarios. Can’t say I’ve achieved anything definitive there, but I don’t know that my experiments really apply to scaled-up situations.

My general impression is that, unless I have a very good reason for using it – probably involving the kind of script in which I’m not generally interested at this time – I should avoid it. Yet I’ll read suggestions that I could use buffering in one or another normal context (e.g., a shortcode that renders a large block of HTML), and I often see it being used in code by people whose work I admire and try to emulate. I’ve seen the familiar ob_start() etc. sequences applied for rendering even very minimal output that is not further adjusted: a menu or other short list, for example.

I have also seen people assert that there is simply no need for output buffering in well-written code, except in peculiar situations. See StackOverflow Q&A’s here Why use output buffering in PHP?, to give one example. Others will say it’s useful ONLY when some manipulation of the output is necessary – like a preg_replace of content – but you don’t need an output buffer to do that kind of thing (any ol’ variable will do).

In most real world instances of the sort I encounter, some version of page caching will also be in use, and sometimes several different plug-ins each with its own caching. Considering how many functions will themselves employ numerous nested/secondary HTML-producing functions, you could easily produce thousands of little nested buffered blocks per page: Suppose a foreach loop produces n number of blog-comments within a larger page: Each blog-comment is rendered by a function, and could be buffered separately. The each-comment function could be called within the foreach loop of the function that outputs the comment thread, and its output could also be buffered. Then the function that outputs the post that includes the comment thread could be output-buffered before being rendered. The entire page, including sundry independently output-buffered templates, plug-ins, widgets, menus, etc., etc., could also be output-buffered.

At what point would any of it be useful or, alternatively, completely counterproductive?

If the answer involves any element of “well, you wouldn’t notice in your blog, but you’d need it for BuzzFeed or the New York Times,” or the reverse, how would I estimate when the point has been reached?

At this point, I’m leaning toward writing the code as cleanly as possible, and letting (what I understand to be) built-in PHP, browser, server, etc., buffering and explicit caching functions do the work of making the page or its elements load efficiently and quickly, which is the real objective, no?


WordPresser
Home Page Public Email Twitter Facebook YouTube Github  

WordPresser: Writing since ancient times, blogging, e-commercing, and site installing-designing-maintaining since 2001.

Posted in Using WordPress, Web Design Tagged with: , ,
Commenter Ignore Button by CK's Plug-Ins

Leave a Reply

Your email address will not be published. Required fields are marked *

*

WordPress Plug-In Notes

  1. Realizing the Commentariat (May 8, 2015)
  2. Child of Mog; Extraordinary Comments (May 25, 2015)
  3. Patronize 'Em: WordPress Draft Post Docket with Subscription and Donation Options (June 9, 2015)
  4. Realizing The Commentariat: Phase 2 (June 22, 2015)
  5. Pseudo-Redacting Spoilerer (July 25, 2015)
  6. Spoiling you some more (August 5, 2015)
  7. Testing Ajaxified Comments - Experiment Halted (August 11, 2015)
  8. New New Since Last Visit Comments Comments (August 16, 2015)
  9. WordPress Comment Nesting Unbound (August 22, 2015)
  10. The Snake Is Implemented (August 25, 2015)
  11. Comments Since Last Visit Reloaded, Reloaded, Testing Post (August 31, 2015)
  12. Comments Since Last Visit, Reloaded, Augmented, Installed, In Two Steps (September 13, 2015)
  13. Coming Soon (I Think!): Author Bios (September 25, 2015)
  14. How to Do Backlinking Footnotes (November 30, 2015)
  15. Who or What Is Using "Commenter Archive" and "commenter-thread"? (February 16, 2016)
  16. Enabling WordPress Press This for HostGator Sites (March 9, 2016)
  17. Linkback Your Xpost: A Simple WordPress Filter Function (March 14, 2016)
  18. Add Amazon Affiliate Tags to WordPress Posts <i>and</i> Comments Automatically (March 19, 2016)
  19. Finding Lost WordPress Widgets after Core Upgrade (March 21, 2016)
  20. Plug-In Away... and the Iron Law of Irony (April 16, 2016)
  21. To o-b or not to o-b (output-buffering in WordPress) - UPDATED (April 24, 2016)
  22. Output-Buffering and Extensible WordPress Plug-Ins (May 21, 2016)
  23. Getting Right with Image Rights: WP Replace Unlicensed and Broken Images Plug-In (June 17, 2016)
  24. Getting Right with Image Rights: Workflow and Major Minor Upgrade (June 27, 2016)
  25. Getting to Better WordPress Twitter oEmbed (June 28, 2016)
  26. An Alliance of Digital Artists (Art and Work in the Age of Instant Reproducibility) (July 8, 2016)
  27. Comparative Page Loads with and without Image Errors (July 14, 2016)
  28. jQuery-Filling an Input Box in WordPress Admin (July 15, 2016)
  29. Drilling a Hole in the Universe with WP_Query in a Shortcode (September 1, 2016)
  30. Troll-Stomping and Other Sensible Things: #WordPress Plug-In Beta Test/Preview (November 12, 2016)
  31. Commenter Ignore Button Preview Video (November 30, 2016)
  32. Is This Solution for Caches vs Cookies Going to Get Me in Trouble? (November 30, 2016)
  33. Commenter Ignore Button 0.99 (December 21, 2016)
  34. Adding wp.media Multiple Image Selection to WordPress Plug-Ins (January 5, 2017)
  35. Working around an Unexplained Failure of WordPress {$taxonomy} Hooks (January 10, 2017)In Progress: Subscribe!
  36. Better Twitter Embeds 2: Stripping the Convo for the Sake of the Convo (February 19, 2017)

Related Posts:

Noted & Quoted

(0)

President Trump's former campaign chairman Paul Manafort, secretly worked for a Russian billionaire to advance the interests of Russian President Vladimir Putin a decade ago and proposed an ambitious political strategy to undermine anti-Russian opposition across former Soviet republics.

The allegations, if true, would appear to contradict assertions by the Trump administration and Manafort himself that he never worked for Russian interests.

Manafort proposed in a confidential strategy plan as early as June 2005 that he would influence politics, business dealings and news coverage inside the United States, Europe and the former Soviet republics, even as US-Russia relations under Republican President George W. Bush grew worse.

Manafort pitched the plans to Russian aluminum magnate Oleg Deripaska, a close Putin ally with whom Manafort eventually signed a $10 million (£8 million) annual contract beginning in 2006, according to interviews with several people familiar with payments to Manafort and business records obtained by the AP.

Comment →
(0)

The texts, posted on a darknet website run by a hacktivist collective, appear to show Manafort’s family fretting about the ethics, safety and consequences of his work for Yanukovych. And they reveal that Manafort’s two daughters regarded their father’s emergence as a key player on Trump’s presidential campaign with a mixture of pride and embarrassment.

In one exchange, daughter Jessica Manafort writes “Im not a trump supporter but i am still proud of dad tho. He is the best at what he does.” Her sister Andrea Manafort responded by referring to their father’s relationship with Trump as “The most dangerous friendship in America,” while in another exchange she called them “a perfect pair” of “power-hungry egomaniacs,” and asserted “the only reason my dad is doing this campaign is for sport. He likes the challenge. It's like an egomaniac's chess game. There's no money motivation.”

By contrast, the Manafort daughters and their mother seemed much more unsettled about Paul Manafort’s work as a political consultant for Yanukovych’s Russia-backed Party of Regions, which is a subject of renewed interest among investigators probing possible links between Trump’s campaign and Russia.

In one March 2015 exchange that appears to be between the two sisters, Andrea Manafort seems to suggest that their father bore some responsibility for the deaths of protesters at the hands of police loyal to Yanukovych during a monthslong uprising that started in late 2013.

“Don't fool yourself,” Andrea Manafort wrote. “That money we have is blood money.”

Comment →
(1)

If there's anything mitigating the bad news for the White House here, it is that Comey may have also sent subtle signals that the matters under investigation are not principally about the personal conduct of Trump himself. While this is speculation, I do not believe that if Comey had, say, validated large swaths of the Steele dossier or found significant Trump-Russia financial entanglements of a compromising variety, he would have said even as much as he said today. I also don't think he would have announced the scope of the investigation as about the relationship "between individuals associated with the Trump campaign and the Russian government" or "coordination between the campaign and Russia’s efforts"; these words suggest one step of removal from investigating the President himself. If the latter were the case, I suspect Comey wouldn't have used words suggestive of the Flynn-Manafort-Page cabal.

But that's reading a lot into a relatively small number of tea leaves. What is clear is that this was a very bad day for the President. In it, we learned that there is an open-ended Russia investigation with no timetable for completion, one that's going hang over Trump's head for a long time, and one to which the FBI director is entirely committed.

Comment →

State of the Discussion

bob
Ignored
Comments this threadCommenter Archive
+ Yeah, I read C's comments as trying to do a variety of things at the same time, having the effect of making interpretation more difficult. Any [. . .]
Benjamin Wittes: How to Read What Comey Said Today – Lawfare
bob
Ignored
Comments this threadCommenter Archive
+ Sure, so why do they have "work Phones" they take home? Even if they don't have fate of the world responsibilities, who they work [. . .]
Isenstadt and Vogel: Paranoia seizes Trump’s White House – POLITICO

Support This Site?