I am trying to compress the response from a java spring-boot application. I referred to some tutorials and StackOverflow questions and found that I just have to add these lines
server.compression.enabled=true
server.compression.min-response-size=1
server.compression.mime-types=text/html,text/xml,text/plain,text/css,text/javascript,application/javascript,application/json
in the application.properties file, so I went ahead and added those, but after adding these lines, I am getting the Content-Encoding as gzip but the size of the response is the same as before, I also double-checked the size by removing them and the only thing that was changing was the Content-Encoding type and the size isn’t getting affected. I am using the embedded tomcat server for the API which sends the model
public class UpdateUserResponseModel {
private String userId;
private String email;
private int age;
private long aadhaar;
private String streetName;
private String city;
private String Country;
private boolean citizenCheck;
public String getUserId() {
return this.userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getEmail() {
return this.email;
}
public void setEmail(String email) {
this.email = email;
}
public int getAge() {
return this.age;
}
public void setAge(int age) {
this.age = age;
}
public long getAadhaar() {
return this.aadhaar;
}
public void setAadhaar(long aadhaar) {
this.aadhaar = aadhaar;
}
public String getStreetName() {
return this.streetName;
}
public void setStreetName(String streetName) {
this.streetName = streetName;
}
public String getCity() {
return this.city;
}
public void setCity(String city) {
this.city = city;
}
public String getCountry() {
return this.Country;
}
public void setCountry(String Country) {
this.Country = Country;
}
public boolean isCitizenCheck() {
return this.citizenCheck;
}
public boolean getCitizenCheck() {
return this.citizenCheck;
}
public void setCitizenCheck(boolean citizenCheck) {
this.citizenCheck = citizenCheck;
}
}
and my spring-boot version is 2.4.5 Am i missing some thing here?
Advertisement
Answer
This might be the issue when we test with postman, as asked here, so inorder to verify, i tried with chrome and i got the compressed size(transfered over network) and also the actual size which is displayed as (resource size), along with the header “Content-Encoding” as “gzip”.