Search code examples
htmltomcatgzipcontent-encoding

How to set content Encoding in HTML file


I want to use GZIP encoding to my site and how should . I set the content encoding of my html file to gzip.

T tried like this

<html lang="en" pageEncoding="gzip">

I am using Apache Tomcat web server.


Solution

  • You have confused content encoding (gzip, deflate) with page (aka character) encoding (ISO-8859-1, UTF-8, etc.).

    In order to enable gzip compression on Apache Tomcat, you have to do it at the <Connector> level -- and only HTTP connectors are supported. See the compressableMimeType, compression, and compressionMinSize attributes for <Connector> in the Apache Tomcat HTTP Connector Configuration Reference