Great conversation with "MatTheCat" on Github today, regarding HTTP caching headers and the ADR pattern.

A quick summary:

  • You want to return a 304 "Not Modified" response if the proper preconditions are met.
  • You can only tell if the resource is unmodified if you touch some form of storage.
  • In ADR, one rule of thumb is "if it touches storage, it probably goes in the Domain."
  • So you need to do all the precondition-checking in the Domain, not in the Action.
  • The Domain can return a payload indicating "not modified" as appropriate, and the Responder can read that payload status to send back a 304.

You can read the whole thing here. Thanks for the great question Mathieu!

Are you stuck with a legacy PHP application? You should buy my book because it gives you a step-by-step guide to improving you codebase, all while keeping it running the whole time.