Deploys, cache refresh and production pitfalls
A runbook for the parts of a release that fail quietly. Server setup is in Going live and Web server configuration; this page covers what to do on each deploy and the traps around it.
Deploy sequence
Section titled “Deploy sequence”On each node, after the new release is in place:
php artisan capell:upgrade --force --no-interactionnpm ci --no-audit --no-fundphp artisan capell:frontend-after-install --apply --no-interactionphp artisan capell:runtime-refresh --no-interactioncapell:upgrade runs migrations and upgrade steps. capell:frontend-after-install --apply generates the frontend stylesheet and builds it with Vite, because generated CSS is not kept in Git. Deploy recipes give this order for Deployer, Forge and Ploi.
capell:runtime-refresh rebuilds the Capell package cache, clears compiled views, rebuilds the configuration and route caches, warms critical pages, runs Capell Doctor (only failed checks fail this stage; warnings are reported and leave it passed, list them with php artisan capell:doctor --warnings), and finally runs queue:restart so workers pick up the release. It exits non-zero if any stage fails, and a stage that throws is recorded as failed without stopping the others. Prefer it to calling the cache commands yourself. The configuration stage only rebuilds the cache if the configuration was already cached; an uncached install stays uncached.
Then reload PHP-FPM (or Octane), and refresh public HTML as described below.
Stale compiled views after a release switch
Section titled “Stale compiled views after a release switch”Compiled Blade views live under storage/framework/views, which is often shared between releases. After switching current to a different release, or rolling back, a stale compiled view can render the wrong template or print literal placeholder text. capell:runtime-refresh clears views; if you switch releases by hand, run php artisan view:clear as the application user straight after the switch, then clear the public HTML cache.
Refresh public HTML in the right order
Section titled “Refresh public HTML in the right order”When the optional capell-app/html-cache package is installed, public pages are served as stored HTML. Changing templates or shared content does not change them until they are regenerated.
php artisan view:clearphp artisan capell:html-cache:clearphp artisan capell:html-cache:process-stale --suppress-inline-edge-purgeview:clearfirst, so regeneration renders with the new templates.capell:html-cache:clearonly marks every cached URL stale. It printsMarked N URL(s) staleand the old HTML keeps being served until the next step. Pass--processto run the next step inline.capell:html-cache:process-stalere-renders stale URLs (--limit=caps the batch).--suppress-inline-edge-purgeleaves edge purging to you so it happens after verification. Read the summary for failed or deferred URLs.- Verify the origin before purging anything.
- Purge the edge, only if one is configured.
The commands need a queue worker for the jobs they dispatch, and invalidation in scheduled mode relies on the scheduler running capell:html-cache:process-stale. The html-cache package’s invalidation guide covers the invalidation modes and edge drivers.
Verify on the canonical URL
Section titled “Verify on the canonical URL”Request the canonical public URL, with no query string and no session cookie:
curl -sS -D - https://www.example.com/some-page | grep -Ei '^(cache-control|cf-cache-status|age|x-frontend-cache):'A query string can bypass or key differently from the stored page, and a signed-in session bypasses it entirely, so either can look fresh while the cached page is stale. To skip the edge, resolve the hostname to the origin with curl --resolve, as shown in Going live.
Purge the edge last
Section titled “Purge the edge last”Purge Cloudflare only once the origin serves the new content; the order and Cache Rules are in Making Capell fast. Do not rely on per-URL purge alone for a whole-site change. A URL list can miss variants and pagination, and a purge that is accepted but incomplete leaves some pages stale for the rest of their TTL. After a deploy that changes shared layout or assets, purge the zone, then confirm a MISS followed by a HIT. php artisan capell:html-cache:edge-purge:verify --driver=cloudflare checks that the purge driver and credentials are configured without purging.
Maintenance mode caveats
Section titled “Maintenance mode caveats”php artisan down makes Laravel return 503 for web requests. Two side effects catch people out:
- Queue workers stop processing jobs while the application is down unless started with
--force, andschedule:runskips scheduled tasks unless they opt in withrunInMaintenanceMode(). A health check that depends on a worker or scheduler heartbeat cannot pass while the site is down. - During Lockdown, Laravel’s maintenance bypass secret and cookie are ignored for public frontend traffic.
Keep the window short, run php artisan up before verifying queue and scheduler health, and do not treat a worker or scheduler warning raised during maintenance as a deploy failure until you have re-checked after up.
Rollback
Section titled “Rollback”Switch current back to the previous release, then run the same steps as a deploy: view:clear, capell:runtime-refresh (it rebuilds the package cache for the code now running), reload PHP-FPM or Octane, and refresh the HTML cache. Database migrations are not reversed by switching code; see Upgrades and take a backup first.
Failed jobs
Section titled “Failed jobs”Queue and scheduler supervision is in Going live. Failed jobs stay in failed_jobs until you act:
php artisan queue:failedphp artisan queue:retry <uuid>php artisan queue:forget <uuid>php artisan queue:flushRetry only after fixing the cause. Use queue:forget for a single stale row and queue:flush to empty the table. Any monitoring that treats a non-empty failed_jobs table as unhealthy, including a post-deploy gate, will keep failing on a stale row until it is forgotten, so review the list before a release rather than after.
Configuration caching and .env
Section titled “Configuration caching and .env”Once config:cache has run, Laravel stops reading .env. env() called outside config/*.php returns null, and editing .env has no effect until the cache is rebuilt. This affects ad hoc artisan commands too: they load the cached configuration of the release they run from, not the file you just edited.
- Change a value in
.env, then runphp artisan config:cache(orcapell:runtime-refresh) and restart workers and PHP-FPM. - To run one command against a different configuration without touching the cache, point Laravel at a cache path that does not exist:
APP_CONFIG_CACHE=/tmp/no-config.php php artisan config:show app.url. Laravel then loads configuration from the files and.env. - Run
artisanas the same user as PHP-FPM so cache and log files are not created with the wrong owner.
Values stored in the database, such as Admin Settings, are separate from .env. Where Admin owns a value, its stored setting takes over and the matching env var is silently ignored (the activity-collection keys are the documented example in Configuration). Clearing the config cache does not change them.
Scanners, 419 and 429 responses
Section titled “Scanners, 419 and 429 responses”Public sites attract automated probing. Most of it is harmless, but know what it looks like:
419on/livewire/update. Livewire returns a generic, empty419when a request has an expired CSRF token or session, or when a payload is corrupt, tampered with, or tries to change a locked property. A single user seeing it usually has an expired page; a stream of them with no matching sessions is scanner traffic. Do not “fix” it by loosening CSRF.404and405floods for paths like/wp-login.php. Answer known-bad paths in nginx so they never boot PHP, and rate-limit at the edge with a Cloudflare rule. Keep these out of your PHP-FPM budget; see Sizing PHP-FPM.429 Too Many Requests. Capell registers a few Laravel rate limiters: the agent endpoints (capell-agent,capell.agent.rate_limitrequests per minute per host and IP, default 60) and the reporting health endpoint (30 per minute per client IP, see Operational reporting). Behind a proxy, the limiter keys on the client IP, so trusted proxies must be configured or every visitor appears to share the proxy’s address and gets limited together.- Lockdown. If probing becomes an incident, use Lockdown.
Response headers and the edge
Section titled “Response headers and the edge”Anonymous public pages are cacheable. Capell and its packages use private, no-store, or no public header for responses that must not be shared (preview, authoring, language redirects, and similar). A signed-in session cookie must bypass both the static cache and the edge. The header values to send for cached pages, the Cloudflare cache and bypass rules, and the MISS/HIT checks are in Making Capell fast.