0
votes

My hosting provider does not use htaccess to enable gzip. Their support told me to change my HTML file to PHP and add the following at the top:

<?php ob_start("ob_gzhandler"); ?>

However, after using gzipWTF to find out if my site is making full use of gzip, there are a number of assets listed - save only 3 - that are not being gzipped.

If you would, go to gzipWTF, and enter my URL: "http://justinjwilson.com".

Check 'details' as an option. Why is it that most of my JS and CSS files are not gzipped? An easy PHP solution would be best. Remember, I can't use htaccess to enable gzip.

1

1 Answers

2
votes

You're out of luck with the one-liner. Adding that line to the top of the now-PHP HTML page is going to cause PHP to handle the gzip-ing of the page content. But only that page. It has no impact on the external files, because it doesn't process them in any way. (Separate files are separate GET requests from the browser; PHP knows nothing about them).

So you need a solution that will allow PHP to handle the gzip-ing of all of your content. A relatively simple solution would be to write a separate PHP page that would handle the delivery of all of your external files. Something like /resource.php?r=myscript.js. This php script would have the "ob_gzhandler" turned on at the top, and then would simply open the file, and echo it out.