I tried setting up gzip compression for server side included files in nginx.

I have enabled gzip compression in nginx.conf

This is the configuration that I have used:

gzip on;
gzip_vary on;
gzip_disable "msie6";
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_min_length 256;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

I also have ssi on at the server block level.

When I check the response headers for SSI files, it does not show content-encoding header. However, when I check the response header for a .css file or any other file that does not have server side include in it and served from the same server, I get the content-encoding header as gzip.

Therefore, I get a "enable text compression" suggestion in Chrome lighthouse for the SSI files.

I have pasted the response headers from Chrome

For the SSI file:

alt-svc: clear
cache-control: no-cache
content-type: text/html
date: Wed, 23 Jan 2019 05:03:31 GMT
server: nginx/1.14.0 (Ubuntu)
status: 200
vary: Accept-Encoding
via: 1.1 google

For the CSS file:

age: 386917
alt-svc: clear
cache-control: max-age=31536000,public, no-transform
**content-encoding: gzip**
content-length: 30438
content-type: text/css
date: Fri, 18 Jan 2019 16:30:06 GMT
expires: Sat, 18 Jan 2020 16:30:06 GMT
server: nginx/1.14.0 (Ubuntu)
status: 200
vary: Accept-Encoding
via: 1.1 google

What settings should be done to enable gzip compression for SSI files?

Could you please help me solve this?

Thanks for your time.

  • @Alexander Tolkachev Thanks for editing my post and making it more readable. – KSB Jan 24 at 16:17
  • Does SSI returns more or equal then 256 bytes of data? – Alexander Tolkachev Jan 25 at 14:22
  • @AlexanderTolkachev Yes. SSI returns more than 256 bytes of data. SSI gets included in the file that calls it and all includes are at least 2 kilobytes. – KSB Jan 25 at 16:11

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.