Issue
-
The gzip filter is disabled by default, but I enabled it using:
com.liferay.portal.servlet.filters.gzip.GZipFilter=true
-
After enabling it, I tried accessing an image guest URL via Postman, but I noticed that the header response does not include Content-Encoding: gzip. Since our images are large, we aim to compress them in the HTTP response so have exposed a GraphQL API via RestBuilder and want to know if we can apply a gzip filter to the API as an approach to improve performance?
Environment
- DXP 7.4
Resolution
- Liferay has no out-of-the-box way to set up gzip compression for only specific endpoints, if you enable gzip compression, Liferay will compress everything, including API communication, if the receiving client supports gzip compression.
- We recommend setting up gzip compression for optimal performance on the web server, not in Liferay. The web server will yield better performance compared to Liferay since the compression algorithm is compiled on the web server while in the app server it is interpreted. Also tiers sitting in front of the app server, whether they are a web server, a CDN, or a caching layer, may uncompress the response as part of their handling of the content. Enabling gzip in the app server then can slow response times because of this extra effort.
Additional Information