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

[💡 FEATURE REQUEST]: Static HTTP middleware, immutable option. #1985

Open
Warxcell opened this issue Aug 9, 2024 · 7 comments · May be fixed by roadrunner-server/static#126
Open

[💡 FEATURE REQUEST]: Static HTTP middleware, immutable option. #1985

Warxcell opened this issue Aug 9, 2024 · 7 comments · May be fixed by roadrunner-server/static#126
Assignees
Labels
C-feature-accepted Category: Feature discussed and accepted

Comments

@Warxcell
Copy link

Warxcell commented Aug 9, 2024

Plugin

HTTP Middleware (any)

I have an idea!

it would be cool if static HTTP middleware have option immutable - so when turned on - it would scan all files in root dir on startup and cache their properties in memory, so with that option roadrunner won't need Static HTTP middleware slows down request processing by ~10% because RR has to check each request for the corresponding file.
thus enabling static http middleware, will have zero performance impact. Furthermore it can be used to send https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control immutable option.

image

Because some projects may run inside docker with read-only filesystem, so roadrunner can be 100% sure that files WON'T change after startup.

@Warxcell Warxcell added the C-feature-request Category: feature requested, but need to be discussed label Aug 9, 2024
@rustatian rustatian added C-feature-accepted Category: Feature discussed and accepted and removed C-feature-request Category: feature requested, but need to be discussed labels Aug 9, 2024
@rustatian rustatian moved this to 📋 Backlog in Jira 😄 Aug 9, 2024
@rustatian
Copy link
Member

Hey @Warxcell 👋
This is a great idea 👍
Would you be able to send a PR ?

@Warxcell
Copy link
Author

Warxcell commented Aug 9, 2024

Hey @Warxcell 👋 This is a great idea 👍 Would you be able to send a PR ?

I will try, but I don't have any experience with Go. 🤣

@rustatian
Copy link
Member

Sure, you may use a map[string]*os.File to have the list of scanned files. Should also check for nils, handle errors on accessing the file (log them, but not interrupt a request) and delete that file if the user deleted it from the disk, for example.

@rustatian
Copy link
Member

I'll help you on the review stage 😃

@Warxcell Warxcell linked a pull request Aug 9, 2024 that will close this issue
6 tasks
@Warxcell
Copy link
Author

Warxcell commented Aug 9, 2024

roadrunner-server/static#126

this is my progress so far, I have difficulties: how to scan rootDir for files, recursively?

@rustatian
Copy link
Member

@Warxcell You may use filepath.Walk

@Warxcell
Copy link
Author

Warxcell commented Aug 9, 2024

@Warxcell You may use filepath.Walk

Thanks! I think I'm ready, but no idea how to test it tho :D neither found tests for this middleware

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-accepted Category: Feature discussed and accepted
Projects
Status: 📋 Backlog
Development

Successfully merging a pull request may close this issue.

2 participants