eg.
+Site
| +private_files
| | header.php
| | footer.php
| | head.php
| | anlytics.php
| | blah1.php
| | blah2.php
| | blah3.php
| index1.php
| index2.php
every serving file requires header.php
,footer.php
,
head.php
, analytics.php
.
besides
index1.php
requires
blah1.php
and blah2.php
. index2.php
requires
blah2.php
,blah3.php
.<!DOCTYPE html>
<html>
<?php include 'private/head.php'?>
<body>
<?php include 'private/header.php'?>
//rest code
<?php include 'private/footer.php'?>
</body>
</html>
How compressed HTML files can be served without aid of apache module ?
I am not very sure about the reason behind "without aid of apache module". If you mean you do not have the access (or permission) to change apache settings. You can still use gzip from php itself.
Just in your header.php (the first included php which could export any content in your script)
ini_set('zlib.output_compression_level', 1); //the compress level you want, 1 is lowest
ob_start('ob_gzhandler');
For further reading of ob_gzhandler - http://php.net/ob_gzhandler
If you mean you do not want even use any system command which supported by apache or other system modules. You just look for a solution complete by php itself. Yes you can use ob_get_clean() get all the content, then apply some gzip compress to the string, and echo it after. Also, change header to let browser know content is gzip(ed). However, I do not think you would like the performance. Besides, you need to lots extra work, feels completely wasted ;-)
For further reading of ob_get_clean - http://php.net/ob_get_clean
put this before <!DOCTYPE html> <html><?php include 'private/head.php'?> <body>
:
<?php
ob_start("ob_gzhandler");
?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With