Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fileserver: Read Etags from precomputed files #6222

Merged
merged 1 commit into from
Apr 13, 2024

Conversation

armadi1809
Copy link
Contributor

Initial pass at closing #5734

@armadi1809 armadi1809 changed the title Implemented reading static files' etags from precomputed files File Server: read etags from precomputed files Apr 5, 2024
Copy link
Member

@mholt mholt left a comment

Choose a reason for hiding this comment

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

Thanks for the great enhancement! This looks pretty good but I just have a few comments.

modules/caddyhttp/fileserver/staticfiles.go Outdated Show resolved Hide resolved
modules/caddyhttp/fileserver/staticfiles.go Outdated Show resolved Hide resolved
modules/caddyhttp/fileserver/staticfiles.go Outdated Show resolved Hide resolved
@francislavoie francislavoie changed the title File Server: read etags from precomputed files fileserver: Read Etags from precomputed files Apr 11, 2024
@francislavoie francislavoie added the feature ⚙️ New feature or request label Apr 11, 2024
@francislavoie francislavoie added this to the v2.8.0 milestone Apr 11, 2024
@armadi1809
Copy link
Contributor Author

Thanks for taking a look at this Matt. All the feedback discussions should now be resolved.

Comment on lines 666 to 669
_, err := fs.Stat(fileSystem, etagFilename)
if err != nil {
continue
}
Copy link
Member

@mholt mholt Apr 13, 2024

Choose a reason for hiding this comment

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

Is the purpose of this to check whether we can access the file? Maybe we can eliminate this system call and instead just call fs.ReadFile() directly. Then:

if errors.Is(err, fs.ErrNotExist) {
    continue
}
if err != nil {
    return "", fmt.Errorf("cannot read etag from file %s: %v", etagFilename, err)
}

What do you think?

(I just noticed this. sorry. lol)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Much much better. Just changed it. Thanks!

@mholt mholt merged commit 567d96c into caddyserver:master Apr 13, 2024
25 checks passed
@mholt
Copy link
Member

mholt commented Apr 13, 2024

Awesome, thanks for working on this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature ⚙️ New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants