Outerfaces.Odd.Plugs.OddRevCacheHeadersPlug (Outerfaces Dependency Distribution (ODD) v0.2.5)

View Source

Plug for setting cache headers based on rev-pinned URL matching.

This plug sets appropriate cache headers:

  • For rev-pinned assets (rev matched + asset type): Cache-Control: public, max-age=31536000, immutable
  • For bootstrap/non-rev/index HTML: Cache-Control: no-store, no-cache, must-revalidate

The plug uses register_before_send/2 to set headers right before the response is sent, allowing other plugs to modify the response first.

Important: Index HTML is NEVER cached immutably, even if rev-matched, to ensure users always get the latest bootstrap code.

Configuration

plug OddRevCacheHeadersPlug

Requires

This plug should be placed AFTER OddRevProxyPlug in the pipeline, as it relies on the conn.assigns.outerfaces_rev_matched value set by that plug.

The ServeIndex plug should set conn.assigns.outerfaces_served_index = true when serving index HTML to prevent immutable caching.