V
V
Volder2015-06-17 15:49:45
Gzip
Volder, 2015-06-17 15:49:45

Why are gzip files not recognized by the browser (Apache server)?

I struggle with the problem for a day, the files compressed in advance in gzip do not want to be read normally in the browser. Displayed as compressed.
Apache2 web server, here is the http response from the server:

Accept-Ranges:bytes
Cache-control:private
Connection:Keep-Alive
Content-Encoding:gzip
Content-Length:39099
Content-Type:text/css
Date:Wed, 17 Jun 2015 12:43:44 GMT
ETag:"98cb-517998d8fcd00-gzip"
Keep-Alive:timeout=5, max=100
Last-Modified:Wed, 03 Jun 2015 09:19:16 GMT
Server:Apache/2.4.10 (Debian)
Vary:Accept-Encoding,User-Agent

I use .htaccess in CSS directory:
RewriteEngine On

#redirect Konqueror and "old browsers"
RewriteCond %{REQUEST_FILENAME} !\.ngz\.css$
RewriteCond %{HTTP:Accept-encoding} !gzip [OR]
RewriteCond %{HTTP_USER_AGENT} Konqueror
RewriteRule ^(.*)\.css$ $1.ngz.css [L]

<IfModule mod_headers.c>
    Header append Vary User-Agent
#set Content-Encoding for all css files
    <FilesMatch .*\.css$>
  Header set Content-Encoding: gzip
  Header set Cache-control: private
    </FilesMatch>
#drop Content-Encoding in case we send not gzipped file
    <FilesMatch .*\.ngz\.css$>
  Header unset Content-Encoding
    </FilesMatch>
</IfModule>

The method has always worked, and it still works on the local machine. But in production I can’t overcome it.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question