On the off-label benefits of No-Vary-Search
While working on HTTP caching, a refresher, I learned about a recent development that immediately piqued my interest. Authored by Domenic Denicola and Jeremy Roman at Google, the No-Vary-Search HTTP response header field proposal enables a server to declare that some aspects of the URL’s query string are irrelevant for the purposes of caching.
Its syntax can express that the order of parameters doesn’t matter, or that some (or all) of the parameters haven’t influenced the content of the response. Barry Pollard has recently explained how that works in Fixing the URL params performance penalty but, in short, a typical response would look like:
HTTP/2 200
No-Vary-Search: params=("utm_campaign" "utm_source")
Cache performance is all well and good, but I’m more enthusiastic for the header’s potential to fix other things. I’ve written before that I’m not a fan of <link rel=canonical> and the way browsers have decided to use it to inappropriately override the original URL, introducing several annoying problems in the process.
Given the way the canonical link relation is defined and incentivized by search engines, I don’t see it as a salvageable mechanism to obtain ‘clean URLs’.
But if you’ve read about No-Vary-Search and thought to yourself, “gosh, this proposal to unambiguously identify which query parameters can safely be yeeted sure sounds like a swell way to get a nice clean ol’ link” — why yes, yes it is. If servers implemented this header in good faith (and correctly) it could serve as an excellent signal for web browsers wishing to share and bookmark stripped-down URLs.
Big if, but fingers crossed, am I right?