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
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/
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 ?
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?
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now