0

I want to share a problem I had, the fix I found and then ask a question about the reason behind the fix.

The problem

After upgrading to wampserver 2.2, one of my webpages consistently didn't work the first time it was loaded in the browser. This happened with internet explorer, chrome, firefox and safari. When reloaded the page worked in all browsers.

the fix

I decided to implement a better debugging solution and while doing so inadvertently fixed my problem. When I set output_buffering =On in php.ini the page worked correctly.

my code

I'm not going to go into detail here. I'm more interested in theory for how output_buffering could be causing problems. Also I think my code will be more of an eyesore than a help.

  • I used ajax and joomla sessions (external script) to retrieve information for the page.
  • I believe that when output_buffering was off, the joomla session was not able to retrieve values. I'm not able to confirm this yet though.

My question

In what ways can output_buffering= Off adversely affect code? Why?

TryHarder
  • 2,704
  • 8
  • 47
  • 65
  • Output buffering is actually recommended to be turned off on Joomla (see the recommended settings on installing Joomla 2.5). Thus it's probably something to do with your ajax functions than Joomla! – George Wilson Sep 23 '12 at 14:43
  • I thought that was just for Joomla installation. You wouldn't happen to know why output buffering is bad for joomla? Maybe I should put this in a separate question.... – TryHarder Sep 23 '12 at 15:28

3 Answers3

0

Output buffering simply allows you to hold off on displaying data that would otherwise be immediately printed to the browser. These are used largely with templating engines in order to store unrendered templates so that they can be filled in with values. I'm guessing Joomla depends on output buffering to fill in the correct values for its templates, which would explain why you were seeing invalid output.

tdlm
  • 597
  • 3
  • 14
  • I believe that it is recommended not to use output_buffering with Joomla, but that may just be during installation though. – TryHarder Oct 24 '12 at 05:07
0

"I used ajax and joomla sessions (external script) to retrieve information for the page." That is your problem. You're retrieving a content that varies within a certain time delay.

Refer to this, it may help you understand how it works: https://stackoverflow.com/a/2832179/817419

Community
  • 1
  • 1
ASertacAkkaya
  • 651
  • 6
  • 16
0

As it turned out one of the files being called by the webpage was encoded incorrectly. Once I encoded it as UTF8 without BOM my problem was largely fixed. My script would work without output_buffering turned on.

The other part of the problem was that some of the scripts that used Firebug complained of headers already being sent. This stopped the code in its tracks.

TryHarder
  • 2,704
  • 8
  • 47
  • 65