Compression Apache GZIP does not compress js / css in other directories

I am trying to use mod_deflate (and others require an extension) to apply GZIP compression to a 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 tried to fix this by adding:

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

Since I thought that he just won’t recognize the types, but it doesn’t work either. JS and CSS files are located in the root folder / js and the root folder / css, maybe this is a program?

EDIT: I use YSlow @Chrome to see if it works.

+6
source share
1 answer
 ############# # 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 

Actively working. (Compresses all extensions, but images)

+16
source

Source: https://habr.com/ru/post/950909/


All Articles