PageSpeed Insights not seeing the Gzip compression
Asked Answered
S

6

16

I'm trying to speed up my website. Google insights (https://developers.google.com/speed/pagespeed/insights) tells me that a critical problem is to enable GZip compression.

The address of the site is http://user2.net It's based on codeigniter framework.

I have enabled gzip compression with folowing changes to my .htaccess file:

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-javascript


<files *.html>
SetOutputFilter DEFLATE
</files>

I have tested the site with this tool: http://www.gidnetwork.com/tools/gzip-test.php It says that gzip is enabled.

What am I missing?

Snippet answered 6/12, 2012 at 13:29 Comment(2)
Maybe gzip was already enabled before, so you wouldn't see any change.Raccoon
As Mark suggests, find out if GZIP compression was enabled beforehand. checkgzipcompression.com Google Page Speed also tells me I need to enable it, but it is already enabled!Tinner
P
14

Did you try these lines in your .htaccess?

<IfModule mod_deflate.c>
<FilesMatch "\.(html|php|txt|xml|js|css)$">
SetOutputFilter DEFLATE
</FilesMatch>
</IfModule>

It works for my site.

Profant answered 12/12, 2012 at 18:25 Comment(0)
E
9

First, check if gzip is enable in your server. You can use this tool: http://checkgzipcompression.com/

If it's ok, then, check that the compression is working FOR ALL your files. If Google Page Speed Test found on single file without GZIP compression from your server, the website with fail the test.

You can use Google Chrome for this:

  1. Inspect your code; in the image you can see there is Content Encoding GZIP for the html file. enter image description here

  2. Clic on every file and find which doesn't have the GZIP encode; maybe the CSS type o JS type.

  3. When you find it, add the file type to your gzip.conf

This is the simple configuration for gzip.conf

gzip on;
gzip_disable "MSIE [1-6]\\.(?!.*SV1)";
gzip_proxied any;
gzip_types text/plain text/css text/javascript text/xml application/javascript application/x-javascript application/xml application/xml+rss image/x-icon image/svg+xml image/jpeg image/jpg image/png
gzip_vary on;

Good Luck!

Eclectic answered 27/12, 2016 at 7:23 Comment(1)
That can indeed differ per file type. On my site, all file types that I listed in the .htaccess file are gzipped, except the javascript files. (Of course, I listed that type as well.)Fleta
V
3

There are three ways to enable gzip compression - By configuring server settings

For apache -

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-javascript

For nginx

gzip on;
gzip_comp_level 2;
gzip_http_version 1.0;
gzip_proxied any;
gzip_min_length 1100;
gzip_buffers 16 8k;
gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
gzip_disable "MSIE [1-6].(?!.*SV1)";
gzip_vary on;

And by editing .htaccess as shown above

<IfModule mod_deflate.c>
<FilesMatch "\.(html|php|txt|xml|js|css)$">
SetOutputFilter DEFLATE
</FilesMatch>
</IfModule>

Source: Enable compression

Vivianna answered 1/10, 2016 at 5:38 Comment(0)
L
0

It's the redirect, it sets 2 headers

first 301 (or 302, didn't check)

second 200 + gzip

Lisk answered 16/10, 2013 at 8:34 Comment(0)
S
0

For anyone who may be having an "Uncompressed Pages" issue after running a SEMRush site audit, try adding the following to your .htaccess

<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html|txt|css|js|php)$
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>

Always remember to backup your .htaccess file before making any edits, as a simple typing error could cause certain features of your website to fail or even worse - break your entire website.

Reference: https://www.semrush.com/blog/improve-page-load-times-htaccess-file/

Selftaught answered 18/2, 2019 at 18:3 Comment(0)
B
-2

Google has addressed this exact same concern in their FAQ as why would you get the errors to compress/gzip your files.

Checkout from Google's Insights: https://developers.google.com/speed/docs/insights/EnableCompression#FAQ

Earlier they used to have a chome extension but now it has been removed so they point you to https://developers.google.com/speed/pagespeed/insights/ where when you enter any url, they tell which particular files or scripts are still eligible for compression or blocking the page render or both.

Hope this helps.

Bettyebettzel answered 17/7, 2017 at 21:39 Comment(1)
@PaulRoub thank you for your feedback. I am currently new to answering questions. Just updated my answer. Hope that helps. Thanks.Bettyebettzel

© 2022 - 2024 — McMap. All rights reserved.