.htaccess - Gzip/Deflate for CSS from PHP script -


php file generate css content, like:

<php echo 'body {color:white}'; ?> 

i call header like:

<link rel='stylesheet'  href='/style.php' type='text/css' /> 

how can enable gzip/deflate compression file? (the main goal pass google pagespeed insights test).

i try code in .htaccess, it's not working file.

<ifmodule mod_deflate.c> <ifmodule mod_headers.c>     header append vary user-agent env=!dont-vary </ifmodule>     addoutputfilterbytype deflate text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/json <ifmodule mod_mime.c>     # deflate extension     addoutputfilter deflate js css htm html xml </ifmodule> 

also try add header("content-type: text/css;"); php file, it's not working too.

adding code header of style.php helped me:

ini_set("zlib.output_compression", "on"); ini_set("zlib.output_compression_level", "-1"); if(!ini_get(‘zlib.output_compression’)) ob_start(«ob_gzhandler»); 

Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -