yashrs Posted May 24, 2014 Posted May 24, 2014 I want to enable gzip compression on my website.Tried using this code(in the .htaccess):<ifModule mod_gzip.c> mod_gzip_on Yes mod_gzip_dechunk Yes mod_gzip_item_include file .(html?|txt|css|js|php|pl)$ mod_gzip_item_include handler ^cgi-script$ mod_gzip_item_include mime ^text/.* mod_gzip_item_include mime ^application/x-javascript.* mod_gzip_item_exclude mime ^image/.* mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.* </ifModule>Also tried this:AddOutputFilterByType DEFLATE text/plain AddOutputFilterByType DEFLATE text/html AddOutputFilterByType DEFLATE text/xml AddOutputFilterByType DEFLATE text/css AddOutputFilterByType DEFLATE application/xml AddOutputFilterByType DEFLATE application/xhtml+xml AddOutputFilterByType DEFLATE application/rss+xml AddOutputFilterByType DEFLATE application/javascript AddOutputFilterByType DEFLATE application/x-javascriptTell me if somebody has a working solution. 2 Quote
Byron Posted May 24, 2014 Posted May 24, 2014 Short answer, no. See if this thread helps you: http://www.helionet.org/index/topic/6415-gzip-compression/ Quote
yashrs Posted May 24, 2014 Author Posted May 24, 2014 Added this to my php.Works for only a file.<?php if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start("ob_gzhandler"); else ob_start(); ?>Any other code/trick to make it work with javascript and CSS files ? Quote
robev Posted August 5, 2016 Posted August 5, 2016 Sorry to bump this thread but I agree with the OP, the php code snippet only works to compress the php file. It doesn't compress CSS and JS files. Any other solution? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.