Skip to content

fileserver: Add first_exist_fallback strategy for try_files#6699

Merged
mholt merged 3 commits intocaddyserver:masterfrom
dunglas:first_exist_or_fallback
Dec 3, 2024
Merged

fileserver: Add first_exist_fallback strategy for try_files#6699
mholt merged 3 commits intocaddyserver:masterfrom
dunglas:first_exist_or_fallback

Conversation

@dunglas
Copy link
Collaborator

@dunglas dunglas commented Nov 18, 2024

When using modern frameworks such as Symfony and Laravel, by convention, all requests are handled by a front controller named index.php in the document root.

Currently, Caddy does a call to fs.Stat() at each request to check that this file exists, but in case we use such a framework, this call is useless because we know that the file exists.

This PR adds a new first_exist_fallback policy that assumes that the last file in the list always exists.

@mohammed90
Copy link
Member

mohammed90 commented Nov 18, 2024

I don't understand why go get fails now 😑

Edit: Nevermind. It's failing because we're not handling forks properly in that job.

@francislavoie francislavoie added the optimization 📉 Performance or cost improvements label Nov 19, 2024
@francislavoie francislavoie added this to the v2.9.0-beta.4 milestone Nov 19, 2024
@dunglas dunglas changed the title feat: add first_exist_or_fallback strategy for try_files feat: add first_exist_fallback strategy for try_files Nov 19, 2024
@dunglas dunglas force-pushed the first_exist_or_fallback branch from 16ba652 to f3444af Compare November 21, 2024 22:09
@dunglas dunglas marked this pull request as ready for review November 21, 2024 22:10
@francislavoie francislavoie changed the title feat: add first_exist_fallback strategy for try_files fileserver: Add first_exist_fallback strategy for try_files Nov 22, 2024
Copy link
Member

@francislavoie francislavoie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@mholt mholt merged commit efd9251 into caddyserver:master Dec 3, 2024
@dunglas dunglas deleted the first_exist_or_fallback branch December 3, 2024 13:15
mohammed90 pushed a commit to cedricziel/caddy that referenced this pull request Aug 29, 2025
…yserver#6699)

* feat: add first_exist_or_fallback strategy for try_files

* fix tests

* linter
@mohammed90 mohammed90 mentioned this pull request Oct 25, 2025
46 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

optimization 📉 Performance or cost improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants