Page tree
Skip to end of metadata
Go to start of metadata
The HTML Compressor module helps to keep the size of a responses to a minimum. By reducing the response size we will increase transfer speed while decreasing the bandwidth.  

Installation

Maven is the easiest way to install the module. Add the following dependency to your bundle:

<dependency>
  <groupId>info.magnolia.html</groupId>
  <artifactId>magnolia-html-compressor</artifactId>
  <version>${htmlCompressorVersion}</version>
</dependency>

Versions

5.7Magnolia 5.7

Usage

The module uses a filter to compress html responses to a minimum size.

Configuration

The filter is highly configureable. Using bypasses and mappings just about any file could be compressed. 

The module provides an additional filter extending from OncePerRequestAbstractMgnlFilter with two additional configurations: 

Class: info.magnolia.html.compressor.filter.HtmlCompressorFilter

compressCss

optionalfalse

Should the filter compress style blocks within HTML files.

compressJavaScript

optional, false

Should the filter compress script blocks within HTML files.

Bypasses

There are four mapping configurations bootstrapped with the filter. These mappings help control which files should be minimized and which files should not be minimized.

  • extensions: This configuration controls which types of files should be minimized. By default only requests for HTML. Here you can add additional extensions as necessary.

    This configuration has a not property reversing the logic and essentially turning the bypass into a mapping. In other words, do not bypass these allowed extensions. This is how to map requests using extension found in the AggregationState.

  • admincentral: Requests to /.magnolia/admincentral are not minimized.
  • vaadin-resources: Requests to resources in a VAADIN folder are not minimized. 
  • minimized: Requests to resources which contain .min. are not minimized. It's assumed that this is a flag in the filename indicating the file is already in a minimized state. Further processing is not needed.

Mappings

By default there are not any mappings configured but you can map specific URIs to the filter. For example, rather than use an entire extension to map you can target specific files or folders by using a mapping configuration. 

Example

Here is an example using the contact page from the demo site.

With compression:

Without compression:

Warnings

  • This module is at INCUBATOR level.
  • Compression will add more time to the initial request of the page. However, it will reduce the size of the file in the cache.
  • Careful when changing mappings. While it's possible to compress any file type in some cases, such as admincentral, minimizing supporting files can break the application. 
  • Using compressJavaScript can lead to exceptions. If you do embed JavaScript it's a good idea to check the compression in UAT.  MGNLDEMO-332 - Getting issue details... STATUS  

Changelog