PHP flush() ... Would This Be Useful?
Posted: Fri Oct 08, 2010 3:19 pm
In my never ending quest to fine-tune and optimize every aspect of the ISC code, I stumbled upon this page: http://developer.yahoo.com/performance/rules.html#flush
... which says:
1) Does ISC construct (and output) pages in such a way that the "flush()" command would be useful?
2) If so, where should it go?
At first glance, it appears that a logical place to add the "flush()" command would be near the bottom of /includes/display/HTMLHead.php ... but it's difficult for me to determine if, at this point, ISC has actually created a complete <head> that's worth sending out early.
3) Or... am I obsessing about something that will produce gains that are so tiny it will hardly be worth the effort? (Tell me...you can be honest.)
~ Charlie
... which says:
A global search of the php code for ISC 4.07 shows that the "flush()" command is used mostly in admin-related scripts... and a couple of non-admin scripts whose purpose appears to be limited to things other than optimizing the store display.Flush the Buffer Early
When users request a page, it can take anywhere from 200 to 500ms for the backend server to stitch together the HTML page. During this time, the browser is idle as it waits for the data to arrive. In PHP you have the function flush(). It allows you to send your partially ready HTML response to the browser so that the browser can start fetching components while your backend is busy with the rest of the HTML page. The benefit is mainly seen on busy backends or light frontends.
A good place to consider flushing is right after the HEAD because the HTML for the head is usually easier to produce and it allows you to include any CSS and JavaScript files for the browser to start fetching in parallel while the backend is still processing.
Example:
Code: Select all
... <!-- css, js --> </head> <?php flush(); ?> <body> ... <!-- content -->
Yahoo! search pioneered research and real user testing to prove the benefits of using this technique.
- viewfile.php
admin\includes\classes\class.batch.importer.php
admin\includes\classes\class.froogle.php
admin\includes\classes\class.shipments.php
admin\includes\classes\class.subscribers.php
admin\includes\classes\class.upgrade.php
admin\includes\classes\class.vendor.payments.php
admin\includes\converter\class.converter.php
admin\includes\converter\class.exporter.php
includes\classes\class.account.php
1) Does ISC construct (and output) pages in such a way that the "flush()" command would be useful?
2) If so, where should it go?
At first glance, it appears that a logical place to add the "flush()" command would be near the bottom of /includes/display/HTMLHead.php ... but it's difficult for me to determine if, at this point, ISC has actually created a complete <head> that's worth sending out early.
3) Or... am I obsessing about something that will produce gains that are so tiny it will hardly be worth the effort? (Tell me...you can be honest.)
~ Charlie