Sourav
Sourav

Reputation: 17530

Enable GZip compression on serving files

Hiii,
I want to compress output [excluding image only] using GZIP in PHP, how to do so for each type of files [PHP, CSS, JS, HTML] ?
I know the code to work with PHP file only.

Upvotes: 0

Views: 636

Answers (2)

Neddy
Neddy

Reputation: 503

Place this line in your page before any headers or other output.

ob_start("ob_gzhandler");

And for other files you can serve them through php, this could be used if you have mod-rewrite, but no mod-deflate or mod-gzip

Upvotes: 1

Related Questions