Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Unbuffered PHP output in browser using Nginx as web server

Posted on 2013-11-05
5
Medium Priority
?
581 Views
Last Modified: 2013-11-08
Is it possible to configure Nginx to run a PHP script but NOT buffer the output.

e.g. to output the following with numbers showing in the browser every second

for ($i = 1; $i <=10; $i++) {
      echo "$i<br>";
      sleep(1);
}

BT
0
Comment
Question by:brothertom
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 2000 total points
ID: 39624093
Maybe, but there are a lot of issues that you will encounter along the way.  PHP offers flush() to help with this.  You want to read the user-contributed notes carefully.  Flush() means nothing to small output documents.  You may also encounter buffering in the client browser.  Some hosting companies make it impossible to turn off output buffering (which actually makes a bit of sense from a performance standpoint).

If you can tell us from a high-level, non-technical view exactly what you're trying to achieve we may be able to offer some ideas.
0
 

Author Comment

by:brothertom
ID: 39624159
Thanks Ray - points noted.

Essentially, I want to allow the user to post in several hundred lines, of shall we say 'commands', into a textbox (newline delim), then on clicking the Process button, see the results of each 'command' on the web page as they happen (each command could take a second or two).

Buffering would have been easy because I could just echo the results to the output.

I guess I would get more complex and use JS to read each line, make an Ajax call, then display the results of each call by stuffing the DOM, but just a bit too complex for this minor project.

BT
0
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 total points
ID: 39624267
jQuery makes the whole AJAX thing a lot easier, and from your description, that would be the way to go, I think.
http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Jquery/A_10712-The-Hello-World-Exercise-with-jQuery-and-PHP.html
0
 

Author Closing Comment

by:brothertom
ID: 39634582
Thanks for the tips and the excellent Ajax article.
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 39634777
Thanks for the points and thanks for using EE, ~Ray
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question