Last active
April 9, 2021 08:45
-
-
Save appelgran/82d589a889dd989299ed8ec3e66145e7 to your computer and use it in GitHub Desktop.
PageSpeed Insights / Lighthouse and flushing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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>'; ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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>'; ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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>'; ?> |
2. Sleep 5 seconds, then flush
2.1. PageSpeed Insights
https://developers.google.com/speed/pagespeed/insights/?url=http%3A%2F%2Fappelgran.org%2Ftest%2Fsleep-then-flush.php
2.2. Lighthouse in Browser
3. No sleep
3.1. PageSpeed Insights
https://developers.google.com/speed/pagespeed/insights/?url=http%3A%2F%2Fappelgran.org%2Ftest%2Fno-sleep.php
3.2. Lighthouse in browser
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
1. Flush content, then sleep 5 seconds
1.1. PageSpeed Insights
https://developers.google.com/speed/pagespeed/insights/?url=http%3A%2F%2Fappelgran.org%2Ftest%2Fflush-then-sleep.php
![Skärmbild 2021-04-09 101647](https://user-images.githubusercontent.com/4532739/114150783-b7fedf80-991c-11eb-837f-a62294cda799.png)
1.2. Lighthouse in Browser