Cache Validators Middleware#
Handles HTTP conditional requests with ETag and Last-Modified, and short-circuits when appropriate.
Responsibilities#
Evaluate
If-None-Match,If-Modified-Since, and other preconditions before controller work.Return 304 Not Modified or 412 Precondition Failed when conditions match.
Drop stale
Rangeheaders so downstream returns a full200when needed.Auto-attach validators (ETag/Last-Modified) for GET/HEAD responses if missing.
Mark personalized responses as
Cache-Control: private.
Boot placement#
Place it early in preGlobal so we can skip expensive work:
preGlobal: [
\Infocyph\Webrick\Middleware\CacheValidatorsMiddleware::class,
// ... hardening, negotiation, etc.
]