Skip to content

fileserver: skip Glob for try_files patterns without meta characters - #8423

Open
joshbarros wants to merge 3 commits into
caddyserver:masterfrom
joshbarros:perf/8275-try-files-skip-glob
Open

joshbarros wants to merge 3 commits into
caddyserver:masterfrom
joshbarros:perf/8275-try-files-skip-glob

Conversation

@joshbarros

Copy link
Copy Markdown

Fixes #8275

On Unix, try_files calls fs.Glob for every candidate. For a pattern with no glob meta characters, fs.Glob stats the file and then strictFileExists stats it again.

Use the literal pattern directly when it contains none of *?[\, matching the existing Windows path, so each candidate is statted once. The regression test counts Stat calls through a custom filesystem and asserts one call.

On Unix, fs.Glob stats a pattern with no glob meta characters, and strictFileExists stats the same path again. Match the Windows path and pass the literal pattern straight through when it has no *?[ or backslash, so each candidate is statted once.
@caddy-cla

caddy-cla Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

✅ Contributor License Agreement

All identified contributors have signed the CLA. Thank you!

@joshbarros
joshbarros force-pushed the perf/8275-try-files-skip-glob branch from b99459b to 77628c0 Compare November 17, 2026 14:27
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.

fileserver: try_files stats each existing candidate twice

1 participant