Skip to content

[6.x] Serve HEAD requests from the static cache - #15168

Merged
jasonvarga merged 1 commit into
statamic:6.xfrom
lazerg:fix/issue-15165-head-static-cache
Aug 11, 2026
Merged

[6.x] Serve HEAD requests from the static cache#15168
jasonvarga merged 1 commit into
statamic:6.xfrom
lazerg:fix/issue-15165-head-static-cache

Conversation

@lazerg

@lazerg lazerg commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

The static caching middleware only ever reads the cache for GET requests, so a HEAD request to a page that's already cached runs the whole render pipeline anyway. Symfony then throws the body away when it prepares the response, so all that work is wasted. Uptime monitors, crawlers and link checkers tend to use HEAD, and on a half measure site they end up an order of magnitude slower than the equivalent GET.

Laravel routes HEAD requests through the matching GET route, and the cacher keys pages by URL, so a HEAD request can just be served the response that GET already cached. This lets canBeCached() through for HEAD as well.

Writes are untouched. shouldBeCached() still only allows GET, so a HEAD miss renders as before without populating the cache with an emptied response.

Fixes #15165

@lazerg lazerg closed this Aug 11, 2026
@lazerg lazerg reopened this Aug 11, 2026
@jasonvarga
jasonvarga merged commit 48907c4 into statamic:6.x Aug 11, 2026
68 of 123 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HEAD requests bypass the half-measure static cache and trigger a full page render

2 participants