genealabs/laravel-caffeine
Laravel Caffeine keeps user sessions alive by pinging your app with a lightweight AJAX heartbeat, preventing session timeouts and lost form data when users are inactive. Easy to install and configure for Laravel apps.
session.lifetime, middleware and route registration, CSRF interaction, backgrounded tabs, CSP and full-page-cache conflicts, and non-HTML response handling. A well-scoped dependency removes a recurring, hard-to-reproduce bug class from the backlog for the price of a small library. Buying is the default; building is justified only if you already have a session-refresh mechanism or unusual security constraints.Route facade import fix. It is not a feature release. That means it belongs as a rider on the Laravel 13 upgrade programme, not as a standalone initiative competing for roadmap capacity. Decide the team's framework upgrade cadence, and this dependency follows automatically.^12.0.3 on Laravel 11/12, ^13.0 on Laravel 13). Pin explicitly so a routine composer update cannot drag the framework forward unexpectedly mid-sprint.Adopt when:
session.lifetime (Laravel default: 120 minutes) — wizards, multi-step onboarding, long applications, editors, uploads, complex settings screens, admin data entry.Look elsewhere or skip when:
Validate before committing:
file. Store expiry semantics differ and this is the most common place a middleware like this behaves differently than in dev.For executives: This is a low-cost, low-risk dependency that fixes a specific, expensive failure: users losing work when their session expires mid-form. That failure surfaces as abandoned checkouts and applications, "Page Expired" errors, and support tickets — all costly and hard to diagnose after the fact. Version 13.0.0 is a maintenance release adding Laravel 13 support plus a small routing fix; there are no behavior changes and no migration work beyond aligning the package major to our framework major. Recommendation: adopt (or retain), pin the version explicitly, and scope enablement to our long-form surfaces. The only residual risk is single-maintainer bus factor, mitigated by keeping the integration thin, version-pinned, and cheap to replace.
For engineering: Treat this as a small, single-responsibility middleware: it injects a keep-alive snippet into HTML responses and exposes a lightweight GET /caffeine endpoint returning 204 that refreshes the session so CSRF validation succeeds on submit. Integration is hours, not sprints. Register the middleware, publish the config, derive the expiration value from session.lifetime rather than a hardcoded default so the two cannot drift, and confirm the route registers correctly (the 13.0.0 Route facade import fix is relevant if you have customized published assets). Three gates before enabling: CSP must permit the script (nonce/hash/external-script option), no full-page cache may store a response carrying it, and the keep-alive route must live in the same session/auth domain as the forms. Verify on the production session driver. Then sequence: pin the dependency now (immediate, reversible, no behavior change), qualify Laravel 13 separately, and enable per route group behind a feature flag — keep the two changes independently revertible so a rollback of one does not force a rollback of both. Add monitoring on 4xx rates for the keep-alive route before the first production rollout, because the failure mode is silent: forms still render, and users only discover the problem when they lose their work. Finally, assign a named owner for version tracking so this dependency appears on every future framework upgrade checklist.
How can I help you explore Laravel packages today?