Skip to content

Always set Vary response header to fix caching#4

Open
qrdl wants to merge 1 commit into
mainfrom
fix-vary-header
Open

Always set Vary response header to fix caching#4
qrdl wants to merge 1 commit into
mainfrom
fix-vary-header

Conversation

@qrdl
Copy link
Copy Markdown
Collaborator

@qrdl qrdl commented May 28, 2026

No description provided.

Copilot AI review requested due to automatic review settings May 28, 2026 07:52
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the html2md proxy-wasm filter to ensure downstream caches correctly separate converted Markdown responses from unconverted HTML by always varying responses on the internal Convert request header.

Changes:

  • Always add/merge Vary: Convert in on_http_response_headers so caches don’t reuse the wrong representation across requests.
  • Split the Markdown MIME constant into request vs response values and set response Content-Type to include charset=utf-8.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread html2md/src/lib.rs
Comment on lines +70 to +84
if let Some(vary) = self.get_http_response_header("Vary") {
let has_convert = vary
.split(',')
.any(|v| v.trim().eq_ignore_ascii_case(CONVERT_FLAG));
if !has_convert {
let new_vary = if vary.is_empty() {
CONVERT_FLAG.to_string()
} else {
format!("{}, {}", CONVERT_FLAG, vary)
};
self.set_http_response_header("Vary", Some(&new_vary));
}
} else {
self.add_http_response_header("Vary", CONVERT_FLAG);
}
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.

2 participants