You say this :
I am wanting to use ob_start
("ob_gzhandler");
to compress CSS
files
I would rather serving and compressing JS/CSS (well, static) files is the job of the Web server (ie, Apache), and not PHP.
About that, you can take a look at mod_deflate
-- at least, if you are using Apache 2.
all files on my site get loaded
(included) through the index file
Is that really necessary ? You're having PHP work with no apparent (?) reason, that way.
(Note that even if CSS/JS files are served through PHP, Apache should be able to compress them with mod_deflate
; same is also true for HTML, JSON, ... btw)
Another advantage of not going through PHP to server those files is that it would be easier to get them served by another server, as your site will grow (if it grows enough, actually) :
- you could have a bunch of "PHP servers", to process PHP pages
- and one or two "static-files servers", to server only CSS/JS/images, and lighten the load or your "application servers" ; no need for PHP on these ones ; you could also use something like lighttpd instead of Apache
That being said, ob_start
says this :
Output buffers are stackable, that is,
you may call ob_start() while another
ob_start() is active. Just make sure
that you call ob_end_flush() the
appropriate number of times. If
multiple output callback functions are
active, output is being filtered
sequentially through each of them in
nesting order.
So, I think the answer to your question is "yes" :-)