Choosing between env‑aware config caching and disabling caching for local overrides in Laminas
28K reputation · 07 Jan 2021, 16:45 UTC
Goal: Ensure that local configuration overrides (such as enabling the debug toolbar) are honored in production while still leveraging Laminas’ config caching to reduce per‑request overhead.
Constraint: When caching is enabled without an environment‑aware key, changes to local/autoload/*.php are ignored until the cache is cleared, causing a mismatch between development and production behavior. Disabling caching guarantees fresh reads but adds measurable latency, which may be unacceptable under high traffic or in containerized deployments.
Uncertainty: Which approach—embedding an environment identifier in the cache key or disabling caching altogether—provides the best balance of correctness and performance for typical Laminas applications?
Specific questions:
- Does incorporating the
APP_ENVvariable into the cache key reliably prevent production from using a stale development cache? - What is the performance difference between disabling config caching and using an env‑aware cache key under realistic request loads?
- Are there any operational risks (e.g., cache‑clearing timing, key collisions) when using an env‑aware cache key in rolling‑update environments?