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

Add support for "If-Modified-Since" and "Last-Modified" #224

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

hugmouse
Copy link
Contributor

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.

Chrome network tab that shows status "200" and status "304" for cached files

continue
}

modTime := fileStats.ModTime()
Copy link

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,
Copy link

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
Copy link

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()
Copy link

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
Copy link

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?

@juev
Copy link

juev commented Apr 12, 2024

I did some research today on how this tag affects caching on the cloudflare side.
alas, when I make requests, I always see the answer 200, never 304. And the file also starts to be given out of date even if checked with curl.

@hugmouse hugmouse marked this pull request as draft April 12, 2024 16:14
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.

None yet

2 participants