Skip to content

Instantly share code, notes, and snippets.

@appelgran
Last active April 9, 2021 08:45
Show Gist options
  • Save appelgran/82d589a889dd989299ed8ec3e66145e7 to your computer and use it in GitHub Desktop.
Save appelgran/82d589a889dd989299ed8ec3e66145e7 to your computer and use it in GitHub Desktop.
PageSpeed Insights / Lighthouse and flushing

The results will be posted in comments

<?php echo '<p>' . date('Y-m-d H:i:s') . ' pre flush()</p>'; ?>
<?php echo '<p style="font-size:8px;word-wrap:nowrap;">' . str_repeat('padding', 4096) . '</p>'; ?>
<?php flush(); ?>
<?php echo '<p>' . date('Y-m-d H:i:s') . ' pre sleep(5)</p>'; ?>
<?php sleep(5); ?>
<?php echo '<p>' . date('Y-m-d H:i:s') . ' done</p>'; ?>
<?php ob_start(); ?>
<?php echo '<p>' . date('Y-m-d H:i:s') . ' after ob_start()</p>'; ?>
<?php echo '<p>' . date('Y-m-d H:i:s') . ' pre sleep(5)</p>'; ?>
<?php echo '<p style="font-size:8px;word-wrap:nowrap;">' . str_repeat('padding', 4096) . '</p>'; ?>
<?php sleep(5); ?>
<?php echo '<p>' . date('Y-m-d H:i:s') . ' pre ob_end_flush()</p>'; ?>
<?php ob_end_flush(); ?>
<?php echo '<p>' . date('Y-m-d H:i:s') . ' done</p>'; ?>
<?php echo '<p style="font-size:8px;word-wrap:nowrap;">' . str_repeat('padding', 4096) . '</p>'; ?>
<?php echo '<p>' . date('Y-m-d H:i:s') . ' done</p>'; ?>
@appelgran
Copy link
Author

appelgran commented Apr 9, 2021

Comment

The PageSpeed Insights result to test 2. Sleep 5 seconds, then flush is very unexpected. Seems like an error. After revisiting the test I noticed I've echo'ed before calling ob_start() so that could have been sent early. But after I corrected the code I still got the same unexpected results. Still some BOM or some other byte can be sent early but it can hardly be called Contentful.

Note: The Lighthouse tests were performed in Vivaldi 3.7.2218.52 but the results are equal to those in Google Chrome 89.0.4389.114.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment