Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to use etag caching directly in my application / verify the eTag in my Application. How is it possible to route the "If-None-Match" header to the backends? It seems that Varnish is cutting out this header by default.

share|improve this question

You can rewrite it to a different header that varnish doesn't know about, and then read that header in your backend instead.

At the top of vcl_recv, try:

set req.http.X-If-None-Match-Previously = req.http.If-None-Match;

and then read the X-If-None-Match-Previously header in your application.

I'm not sure how that's going to interact with your caching but that will pass the header data through if Varnish is stripping it from its backend requests.

share|improve this answer
Are you sure that it should work? I'm sending the headers but the app does not receive anything. even set req.http.X-If-None-Match-Previously = "test"; does not work. – Tobias Jul 28 '12 at 8:05
Any ideas? Seems not to be possible to add various headers? – Tobias Jul 31 '12 at 13:21
Definitely possible. Is there something between varnish and your app that might be stripping them? – Pax Aug 1 '12 at 1:28
Okay, may fault: set req.http.X-If-None-Match-Previously = "foo" works now. But it seems that req.http.If-None-Match was stripped before by Varnish :-( Any Ideas on this? Inline C? – Tobias Aug 1 '12 at 13:56
Stupid me, see the real solution below. – Tobias Aug 1 '12 at 15:53
up vote 0 down vote accepted

Okay, solved it: Varnish does not remove the If-None-Match header. It was just my web app delivered from cache while requests were still coming in. Chrome served the old version of the page. COUGH. COUGH. COUGH.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.