class

Marten::CDNCache::Middleware

Inherits Marten::Middleware < Reference < Object

Sets Cache-Control per the configured rules and (in Task 7) strips Set-Cookie on public responses so a CDN will cache them.

Register it as the OUTERMOST middleware (first in config.middleware) so it processes the response LAST — after Session/Flash have set their cookies. See the README for the AssetServing ordering trap.

Constants

INTERNAL_POLICY_HEADER = "X-Marten-CDNCache-Policy"

Internal-only header by which a handler concern selects a policy. The middleware reads and then DELETES it, so it never reaches the client.

Instance methods

Calls the middleware for a given HTTP request and returns a HTTP response.

This method must be implemented by subclasses: it takes a request argument (the current HTTP request) and a get_response proc that allows to get the final response. This proc might actually call the next middleware in the chain of configured middlewares, or the final matched handler. That way, the current middleware have the ability to intercept any incoming request and the associated response, and to modify them if applicable.