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

templates: delete ETag and Last-Modified headers in ServeHTTP #2338

Merged
merged 1 commit into from Nov 18, 2018

Conversation

crvv
Copy link

@crvv crvv commented Nov 12, 2018

1. What does this change do, exactly?

In tempates middleware, delete the two headers related to cache.

2. Please link to the relevant issues.

#1920

3. Which documentation changes (if any) need to be made because of this PR?

None.

4. Checklist

  • I have written tests and verified that they fail without my change
  • I have squashed any insignificant commits
  • This change has comments for package types, values, functions, and non-obvious lines of code
  • I am willing to help maintain this change if there are issues with it later

@crvv crvv requested review from mholt and tw4452852 November 14, 2018 04:32
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.

Hm, yeah, this is probably a good idea, since templates are dynamically-rendered. (If we apply the caching headers more carefully in a way that considers this fact, we can re-implement it later.)

Thanks!

@@ -110,6 +110,10 @@ func (t Templates) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error
// set the actual content length now that the template was executed
w.Header().Set("Content-Length", strconv.Itoa(buf.Len()))

// delete the headers related to cache
Copy link
Member

Choose a reason for hiding this comment

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

Note for future work: I think a comment for the next two lines is good, but this comment just restates what is obvious from the code. Better would be to have a comment explaining WHY the next two lines are present.

Copy link
Member

Choose a reason for hiding this comment

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

FWIW I think it's at least more useful than just stating the obvious, because it's specific domain knowledge that ETag and Last-Modified are cache-related. Not everyone would know that. But I agree that it could explain why those headers are being deleted.

@mholt mholt merged commit ce0988f into caddyserver:master Nov 18, 2018
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

3 participants