NAME
Plack::Middleware::ETag - Adds automatically an ETag header.
VERSION
version 0.06
SYNOPSIS
use Plack::Builder;
my $app = builder {
enable "Plack::Middleware::ETag", file_etag => [qw/mtime size/];
sub {['200', ['Content-Type' => 'text/html'}, ['hello world']]};
};
DESCRIPTION
Plack::Middleware::ETag adds automatically an ETag header. You may want to use it with Plack::Middleware::ConditionalGET.
my $app = builder {
enable "Plack::Middleware::ConditionalGET";
enable "Plack::Middleware::ETag", file_etag => [qw/mtime size/];
sub {['200', ['Content-Type' => 'text/html'}, ['hello world']]};
};
CONFIGURATION OPTIONS
file_etag
If the content is a file handle, the ETag will be set using the modified time and the file size. You can select which attributes of the file will be used to set the ETag:
enable "Plack::Middleware::ETag", file_etag => [qw/size/];
Supported attributes are
- mtime
-
This is the file modification time.
- size
-
This is the file size.
- inode
-
This includes the inode number.
It is no longer included by default since version 0.06, and is considered a potential security issue.
cache_control
It's possible to add 'Cache-Control' header.
enable "Plack::Middleware::ETag", cache_control => 1;
Will add "Cache-Control: must-revalidate" to the headers.
enable "Plack::Middleware::ETag", cache_control => [ 'must-revalidate', 'max-age=3600' ];
Will add "Cache-Control: must-revalidate, max-age=3600" to the headers.
check_last_modified_header
Will not add an ETag if there is already a Last-Modified header.
SOURCE
The development version is on github at https://github.com/robrwo/perl-Plack-Middleware-ETag and may be cloned from https://github.com/robrwo/perl-Plack-Middleware-ETag.git
SUPPORT
Only the latest version of this module will be supported.
This module requires Perl v5.14 or later. Future releases may only support Perl versions released in the last ten (10) years.
Please report any bugs or feature requests on the bugtracker website https://github.com/robrwo/perl-Plack-Middleware-ETag/issues
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
Reporting Security Vulnerabilities
If the bug you are reporting has security implications which make it inappropriate to send to a public issue tracker, then see SECURITY.md for instructions how to report security vulnerabilities.
AUTHORS
Franck Cuny <franckcuny@gmail.com>
Robert Rothenberg <perl@rhizomnic.com>
CONTRIBUTOR
Leo Lapworth <leo@cuckoo.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2015, 2026 by Franck Cuny.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.