Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache GZIP compression not compressing js/css in other directories

I'm trying to use 'mod_deflate' (and other requires extensions) to apply GZIP compression to my local hosted site (Apache, 2.4.4.0).

This is the code I'm using (.htaccess):

SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/html text/css text/plain text/xml text/javascript application/x-javascript application/x-httpd-php
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip
Header append Vary User-Agent env=!dont-vary

I've tried to fix it by adding:

AddType text/css .css
AddType text/javascript .js

Since I thought it just wouldn't recognize the types but it didn't work either. The JS and CSS files are both located in rootfolder/js and rootfolder/css, could that be the program?

EDIT: I'm using YSlow @ Chrome to see if it's working.

like image 363
Jevgeni Geurtsen Avatar asked Aug 02 '13 13:08

Jevgeni Geurtsen


1 Answers

#############
# TYPES FIX #
#############
AddType text/css .css
AddType text/javascript .js

####################
# GZIP COMPRESSION #
####################
SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/html text/css text/plain text/xml text/javascript application/x-javascript application/x-httpd-php
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip
Header append Vary User-Agent env=!dont-vary 

Acutally works. (Compresses all extensions but images)

like image 176
Jevgeni Geurtsen Avatar answered Nov 18 '22 07:11

Jevgeni Geurtsen