0

If you have a large class that executes after output(headers/text) is already sent, will that have any affect on your applications performance?

Edit: To clear things up, when output is sent, default headers are sent with it.

2
  • So, what's your question? The title or the content? Commented Sep 2, 2009 at 7:48
  • 2
    What exactly are you asking? Your title doesn't seem to match your question. Commented Sep 2, 2009 at 7:48

3 Answers 3

3

The execution speed of the PHP will be the same regardless of whether the headers have been sent.

If you can send some HTML (for example the <head> section) then it can actually make your page load faster, as the client can begin to download CSS and javascript files, and start to render the page if you send enough HTML.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, exactly what I was looking for and more.
1

Headers slowing php code : i think no more than any other instructions, i may be wrong.

And the fact that output had already been send doesn't mean further code will run slower, or that would be a very strange behavior.

Comments

0

I suppose that you say that some content is already flushed out to the browser in which case, adding new headers may not have any impact on the previously sent headers - but doing something unnecessarily that doesnt affect anything will increase the overhead for sure(and for nothing). This is assuming that all the functionality that the "large class" does is to add headers.

You should consider re-arranging some code then.

https://www.php.net/manual/en/function.header.php

2 Comments

Trying to add a header after output has been sent to the browser will fail.
Yeah, that is what I pointed out - it is akin to doing something unnecessarily.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.