-
Notifications
You must be signed in to change notification settings - Fork 25
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
Add support for "If-Modified-Since" and "Last-Modified" #224
base: master
Are you sure you want to change the base?
Conversation
… "Last-Modified" For caching, of course!
continue | ||
} | ||
|
||
modTime := fileStats.ModTime() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How it works for embedded files?
static.FS.Open(name) returns a file either from embedded or from the file system
I'm not sure that this point will be worked out correctly here.
misc/handlers.go
Outdated
|
||
filesData = append(filesData, fileData{ | ||
Content: file, | ||
ModTime: modTime, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And where do we use this parameter?
As far as I can see, we define it, but we don't use it anywhere.
if err != nil { | ||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If file open, but we can’t stat file, we will continue. But file still open
|
||
filesData = append(filesData, file) | ||
|
||
defer file.Close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defer in for cycle it’s not good idea.
File will be close only on exit from func
defer file.Close() | ||
} | ||
|
||
// Step 2: Check the "If-Modified-Since" header in the request |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This header used in browser? Or we should specify it?
I did some research today on how this tag affects caching on the cloudflare side. |
Might be a fix for #222 , but might need some more testing. And maybe add support in a similar way for other static stuff in the project.
Tested in docker, seems to be working as expected.