Proposal/specs for backend conditional requests / aka "GET If-Modified-Since" (GET IMS))

Poul-Henning Kamp phk at phk.freebsd.dk
Mon Oct 4 15:18:38 CEST 2010


I had hoped to ponder this on the train from Frankfurt to Hamburg saturday
but got sidetracked by other issues and code, so bear in mind that this
is not thought out as much as I would like.

First issue:  If-Modified-Since requests to backend.
----------------------------------------------------

I don't see any benefit from adding two new vcl-subs for this, in my
world it should work the following way:

	Cache lookup.
		Find valid in-ttl object -> vcl_hit
			Find valid in-grace object -> vcl_miss (with obj.*)
			Find nothing usable -> vcl_miss (without obj.*)

	Before vcl_miss is called, we prepare the bereq.* as today
	but if we have a graced object, we make it an If-Modified-Since
	request by default.

	(... unless parameter (per backend flag ?) tells us not to).

	If people don't want to IMS certain objects, they remove the
	IMS header in vcl_miss{}, and things automatically DTRT.

	If we get a "304 Not Modified" back, we always instantiate
	a new objcore+obj and if the stevedore insists (-spersistent)
	we will copy the body as well.  We change the beresp.status
	to 200 to hide the IMS action from vcl_fetch{}

	At this point we let go of the ref on the graced object as
	we have the new one fully usable at this point.

	And apart from all the nitty gritty, that is it as far as
	I can tell.

Second issue: deliver graced content under VCL control
------------------------------------------------------

Now that we have the graced object in vcl_miss{}, we might
as well allow return(deliver) on it, should people desire
to do so, and one obvious case would be:

	sub vcl_miss {
		if (!req.backend.healty && obj.status) {
			return (deliver);
		}
	}

Third issue: how does that work with saint mode
-----------------------------------------------

Saint mode consists of two things:

A)  Per backend list of unhealty URL's which affect backend 
    health status.  Forget about this, it's not relevant here.

B)  Ability to deliver graced content if backend fetch fails.

Since we have extended the graced-obj ref into vcl_miss{} above,
it is not a long stretch to hold unto it until vcl_fetch{} also,
and avoid the currently necessary restart in order to return graced
content on backend failure.

In order to not confuse the syntax more than necessary, we
should probably introduce "return (deliver_graced)" both
in vcl_miss{} and vcl_fetch{}.


Comments ?

-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.




More information about the varnish-dev mailing list