Forum Moderators: phranque

Message Too Old, No Replies

Gzip compression - other things to compress

         

killua

7:12 am on Oct 3, 2017 (gmt 0)

10+ Year Member



I have gzip compression enabled on my server for faster browsing.

I have below setup in my cPanel >> Optimize Website >> Compress Content
-----
Compress the specified MIME types.
text/html text/plain text/xml text/css text/javascript application/javascript application/x-javascript
-----

Recently, I've been using a few PHP scripts, too, especially Formmail that is programmed with PHP. Do you recommend that PHP scripts are compressed, too? If so, how will I change the above code so that PHP is added as one of the MIME types ?

topr8

8:39 am on Oct 3, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



you don't serve php scripts to the client ... only the output returned by the script (on the server), which would normally be served as text/html

killua

9:39 am on Oct 3, 2017 (gmt 0)

10+ Year Member



In my settings above javascript is included in MIME types. So if scripts don't serve to the client, does it mean this portion "text/javascript application/javascript application/x-javascript" is also not necessary?

phranque

10:45 am on Oct 3, 2017 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



whether the response that serves the html document or javascript is generated by a php script or by a static file doesn't matter to the output filter stage where gzip compression occurs.
at that point the response body is already transmitted with the MIME-type specified in the Content-Type header.
therefore as long as your php script is serving html documents with the text/html MIME-type specified they should be compressed with your cpanel configuration setting.

keyplyr

11:06 am on Oct 3, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



So if scripts don't serve to the client, does it mean this portion "text/javascript application/javascript application/x-javascript" is also not necessary?
topr8 said the PHP process doesn't get compressed, only the output. That doesn't mean *all* scripts.

JavaScript is user-side, meaning the browser downloads the script and runs it... So yes, compressing JavaScript is preferred.

However you should check with your server admin or support team to see if all those JS compression types are supported.

killua

11:07 am on Oct 3, 2017 (gmt 0)

10+ Year Member



I see. In that case, I will leave the settings as is then.