Skip to content

Repository files navigation

Maho NoCacheHeader

Maho Commerce License PHP PHPStan Level

A Maho module that sends Cache-Control: no-store, no-cache, must-revalidate and Pragma: no-cache headers on all frontend pages. Configurable via admin.

When to use this module

Maho supports the browser's back-forward cache (bfcache) natively via the pageshow JavaScript event (see PR #991). This is the recommended approach: pages are served from bfcache for instant navigation, and the pageshow handler refreshes dynamic content (cart sidebar, checkout state) when the page is restored.

This module is intended for custom or legacy themes that do not implement the pageshow event (or equivalent client-side logic) and need to prevent stale dynamic content by disabling bfcache on the server side via Cache-Control: no-store.

Requirements

  • PHP >= 8.3
  • Maho Commerce

Installation

composer require empiricompany/maho-nocacheheader

Clear the cache after installation:

./maho cache:flush

Configuration

Go to System → Configuration → Web → Cache-Control Header and set Add Cache-Control: no-store, no-cache, must-revalidate and Pragma: no-cache headers to Yes.

The setting applies to frontend only — admin panel is not affected.

Development

This module ships with the standard Maho CI gates:

  • PHP CS Fixer (dry-run) — composer cs
  • PHPStan (level 8) — composer phpstan
  • Rector (dry-run) — composer rector
  • PHP / XML syntax checks — automatic on CI

Run composer install and composer check to run all the gates locally before pushing.

License

OSL-3.0 / AFL-3.0

About

Adds `Cache-Control: no-store, no-cache, must-revalidate` and `Pragma: no-cache` headers globally on all frontend pages, restoring the default behavior from OpenMage. Configurable via admin.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages