1

I am doing some tests with gzip, I have manually compressed the CSS and JS with gzip. The size of the JS has dropped from 33kb to 7kb.

The problem is when I look in the network tab in Chrome or Firefox it shows me that the file has 33kb instead of 7kb. The extension is still gz so it seems that it is the same file, it doesn't serve me the uncompressed version. If I right click on the file in the network tab and then save it on HDD I see that the size is 33kb not 7kb even though the extension is still gz. If I try to dezarhivate with 7zip it cants.

On the "Request header" for the js gz file I have "Accept-Encoding: gzip, deflate" on the "Response header" I have "Transfer-Encoding: chunked Vary Accept-Encoding"

Do I have to configure the server to allow gzipped css's and js's? is there a way to fix this without changing the server option, maybe a MIME? The server runs Apache/2.2.15 (CentOS).

I have this on htaccess, do I have to change this?

AddEncoding gzip .gz
<Files *.css.gz>
    ForceType text/css
</Files>
<Files *.js.gz>
    ForceType text/javascript
</Files>
<FilesMatch .*\.(js|css)>
    RewriteEngine On
    RewriteCond %{HTTP_USER_AGENT} !MSIE
    RewriteCond %{HTTP:Accept-encoding} gzip
    RewriteCond %{REQUEST_FILENAME} (.*)/(css|js)/([0-9]+)(.*)
    RewriteCond %1/%2/tmp/%3%4.gz -f
    RewriteRule ^(.*)$ %1/%2/tmp/%3%4.gz [QSA,L]
    RewriteCond %{REQUEST_FILENAME} (.*)/(css|js)/([0-9]+)(.*)
    RewriteCond %1/%2/tmp/%3%4 -f
    RewriteRule ^(.*)$ %1/%2/tmp/%3%4 [QSA,L]
</FilesMatch>
  • Have you checked the file contents and size in fiddler to make sure the browser isn't just helpfully reporting the full size of the content? (given you want to see the content, not the compressed version) – tobyd Jun 26 '18 at 9:32
  • I have checked in the Network tab in Chrome both sizes, the size of the file and the content size. Also, i have downloaded the file and it has the full size, not the compressed size. – EPurpl3 Jun 26 '18 at 11:07
  • @todyd now i understood what you meant, after some research, i will install Fiddler. Thanks. – EPurpl3 Jun 26 '18 at 14:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.