Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/dernasherbrezon/fingerprint-maven-plugin

Maven plugin for web resources optimization
https://github.com/dernasherbrezon/fingerprint-maven-plugin

html-minification java jsp nginx optimization web

Last synced: 4 days ago
JSON representation

Maven plugin for web resources optimization

Awesome Lists containing this project

README

        

fingerprint-maven-plugin [![Main Workflow](https://github.com/dernasherbrezon/fingerprint-maven-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/dernasherbrezon/fingerprint-maven-plugin/actions/workflows/build.yml) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=com.aerse.maven%3Afingerprint-maven-plugin&metric=alert_status)](https://sonarcloud.io/dashboard?id=com.aerse.maven%3Afingerprint-maven-plugin)
========================

Fingerprint and optimize web resources.

About
---------------------

This plugin performs several optimizations:
* Resource fingerprinting.
* JS/CSS minification. yuicompressor is used
* HTML minification.

### Fingerprinting

During this process plugin calculates file checksum and prepends it to the file name. All links to this filename will be changed to the fingerprinted version. Original file will be deleted. Fingerprinting used to improve web resource caching. If file checksum is not changed, then the name will be the same and it is safe to add max expires header. Once file contents are changed, checksum will be changed as well. This plugin filters out (recursivly) source directory, detects any resources using the patterns below and copy result (if needed) to the target directory.

The following patterns are used to detect resources eligible for fingerprinting:
* `]+href=["'](.*?)["'][^>]*>`
* `["']([^\s]*?\.js)["']`
* `]+src=["'](.*?)["'][^>]+>`
* `url\(\s*["']?(.*?)["']?\s*\)`
* `]+value="(.*?)"[^>]+>`

After fingerprinting it is safe to add max expires header.

Requirements

* All resources should have absolute paths:
* Valid: ``
* Invalid: ``
* JSP contextPath is supported:
* Valid: ``
* Invalid: ``
* All resources should point to existing files without any pre-processing:
* Valid: ``
* Invalid: `/img/test.png"`
* Invalid: `
com.aerse.maven
fingerprint-maven-plugin
3.6


package

generate





://
//
data:

${basedir}/target/webcombined

${basedir}/target/optimized-webapp

true
true
true


html
jsp
tag


html
jsp
tag
css
js

${cdn}

[hash][name].[ext]


```
* Configure apache or nginx with max expires header. The following example is the configuration for nginx:

```xml
location ~ ^/.+\.(ico|jpg|jpeg|gif|pdf|jar|png|js|css|txt|epf|ttf|svg|woff)$ {
root ;
expires max;
add_header Cache-Control public;
}
```