Ensure fast flush of HTTP headers and HTML head (#2045)

* Ensure fast flush of HTTP headers and HTML head

The fast flush optimisation done in
https://github.com/FreshRSS/FreshRSS/pull/1133 does not seem to work
anymore (need to check if it is related to a PHP version).
Work-around when PHP flush() is not working
Can be tested by adding a `sleep(5);` after:

ee902ee7c4/app/layout/layout.phtml (L27)
Follow-up of the performance checks of
https://github.com/FreshRSS/FreshRSS/pull/2040

* output_buffering in .user.ini for PHP CGI / FPM

* Reuse .user.ini for Docker PHP config

* Longer flush

Flush a bit later, to be compatible with the default value of 4096 for
PHP output_buffering, and thus avoid the need of tuning the value.
pull/2052/head
Alexandre Alapetite 6 years ago committed by GitHub
parent 1f39537158
commit 5b030dcc6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 26
      app/Controllers/indexController.php
  2. 21
      app/layout/layout.phtml
  3. 5
      app/views/index/global.phtml
  4. 5
      app/views/index/normal.phtml
  5. 5
      app/views/index/reader.phtml

@ -32,7 +32,16 @@ class FreshRSS_index_Controller extends Minz_ActionController {
Minz_Error::error(404);
}
$this->view->callbackBeforeContent = function ($view) {
$this->view->categories = FreshRSS_Context::$categories;
$this->view->rss_title = FreshRSS_Context::$name . ' | ' . Minz_View::title();
$title = FreshRSS_Context::$name;
if (FreshRSS_Context::$get_unread > 0) {
$title = '(' . FreshRSS_Context::$get_unread . ') ' . $title;
}
Minz_View::prependTitle($title . ' · ');
$this->view->callbackBeforeFeeds = function ($view) {
try {
$tagDAO = FreshRSS_Factory::createTagDao();
$view->tags = $tagDAO->listTags(true);
@ -40,7 +49,13 @@ class FreshRSS_index_Controller extends Minz_ActionController {
foreach ($view->tags as $tag) {
$view->nbUnreadTags += $tag->nbUnread();
}
} catch (Exception $e) {
Minz_Log::notice($e->getMessage());
}
};
$this->view->callbackBeforeEntries = function ($view) {
try {
FreshRSS_Context::$number++; //+1 for pagination
$entries = FreshRSS_index_Controller::listEntriesByContext();
FreshRSS_Context::$number--;
@ -67,15 +82,6 @@ class FreshRSS_index_Controller extends Minz_ActionController {
Minz_Log::notice($e->getMessage());
Minz_Error::error(404);
}
$view->categories = FreshRSS_Context::$categories;
$view->rss_title = FreshRSS_Context::$name . ' | ' . Minz_View::title();
$title = FreshRSS_Context::$name;
if (FreshRSS_Context::$get_unread > 0) {
$title = '(' . FreshRSS_Context::$get_unread . ') ' . $title;
}
Minz_View::prependTitle($title . ' · ');
};
}

@ -18,13 +18,7 @@
<meta name="msapplication-TileColor" content="#FFF" />
<?php if (!FreshRSS_Context::$system_conf->allow_referrer) { ?>
<meta name="referrer" content="never" />
<?php
}
flush();
if (isset($this->callbackBeforeContent)) {
call_user_func($this->callbackBeforeContent, $this);
}
?>
<?php } ?>
<?php echo self::headTitle(); ?>
<?php
$url_base = Minz_Request::currentRequest();
@ -43,10 +37,19 @@
<?php } ?>
</head>
<body class="<?php echo Minz_Request::actionName(); ?>">
<?php $this->partial('header'); ?>
<?php
flush();
$this->partial('header');
?>
<div id="global">
<?php $this->render(); ?>
<?php
flush();
if (isset($this->callbackBeforeFeeds)) {
call_user_func($this->callbackBeforeFeeds, $this);
}
$this->render();
?>
</div>
<?php

@ -1,6 +1,11 @@
<?php
$this->partial('nav_menu');
flush();
if (isset($this->callbackBeforeEntries)) {
call_user_func($this->callbackBeforeEntries, $this);
}
$class = '';
if (FreshRSS_Context::$user_conf->hide_read_feeds &&
FreshRSS_Context::isStateEnabled(FreshRSS_Entry::STATE_NOT_READ) &&

@ -3,6 +3,11 @@
$this->partial('aside_feed');
$this->partial('nav_menu');
flush();
if (isset($this->callbackBeforeEntries)) {
call_user_func($this->callbackBeforeEntries, $this);
}
if (!empty($this->entries)) {
$display_today = true;
$display_yesterday = true;

@ -1,6 +1,11 @@
<?php
$this->partial('nav_menu');
flush();
if (isset($this->callbackBeforeEntries)) {
call_user_func($this->callbackBeforeEntries, $this);
}
if (!empty($this->entries)) {
$lazyload = FreshRSS_Context::$user_conf->lazyload;
$content_width = FreshRSS_Context::$user_conf->content_width;

Loading…
Cancel
Save