Client Caching (Validation)

This concern adds an ETag header to every response generated by the server so that clients send a If-None-Match header to validate their cache. If the content did not change on the server, the handler will generate a 304 Not Modified response, causing the client to re-use the locally cached data. This way, clients revisiting your web application load faster and the load on your server is reduced.

Kotlin
val content = Layout.create()
    .add(ClientCache.validation())

The ETag is generated from the checksum of the content that should be served to the client. Dependent on the kind of content (such as a local file resource) the checksum can be calculated quite efficiently. Responses to GET and HEAD requests are tagged, and a handler that sets an ETag itself keeps it.

This concern is part of the default configuration and will automatically be added to your server.