Subject: add GETAJAX verb/method in http protocol

From: Christian RIGONI <[email-masked]>
Date: Tue, 22 May 2012 14:47:19 +0100

Hello everybody,

I could not find this possibility in the mailing lists, so I would like 
to bring up this topic.
By working on html page developpement, I remarked that very often (but 
not always of course), ajax request correspond to information that are 
relative to an html page.
For example, lets define the page http://www.site.com/page.html on a 
server.
The first http verb used for this page is obviously GET.
Then the page is displayed by the navigator on the client.

Now, suppose the user modify an element of the page. It can be useful to 
send a http GETAJAX request to http://www.site.com/page.html in order to 
get the information corresponding to the new element modified by the user.
Actually the problem is adressed by sending a http GET to another page, 
for example www.site.com/page_ajax.html. But may be it can be useful to 
send a http GETAJAX to the page http://www.site.com/page.html.
Another thing which can be usefull, the same page 
http://www.site.com/page.html may have several http ajax request to 
process. So an ajax_id can be added to the http GETAJAX to differentiate 
the ajax requests.

I hope this request will be helpfull for you and other people.

Sincerely.

_Christian RIGONI_

---

From: "Poul-Henning Kamp" <[email-masked]>
Date: Tue, 22 May 2012 16:34:04 +0000

In message <[email-masked]>, Christian RIGONI writes:

>send a http GETAJAX request [...]

Varnish can handle pretty much any weird request, but you have to
neuter some of the rfc2616 heuristics.

Before vcl_miss{} is called, the req.request is forced to "GET",
you will have to undo that, but I think that is about it.

Something like this should do it:

	sub vcl_recv {
		set req.http.x-real-req = req.request;
	}

	sub vcl_miss {
		if (req.http.x-real-req == "GETAJAX") {
			set bereq.request = "GETAJAX";
		}
		unset bereq.http.x-real-req;
	}

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

---

From: J Ross Nicoll <[email-masked]>
Date: Tue, 22 May 2012 19:54:15 +0100

Christian,

I'm not sure this necessarily makes sense as a separate method; you're 
still taking the same action (getting a resource), it's just the 
presentation that differs. I tend to use query parameters to indicate 
which parts of a resource I want (and an Accept header to indicate I'm 
wanting the response as JSON/XML), is that a reason that doesn't suit?

Ross

On 22/05/2012 14:47, Christian RIGONI wrote:
> Hello everybody,
>
> I could not find this possibility in the mailing lists, so I would 
> like to bring up this topic.
> Now, suppose the user modify an element of the page. It can be useful 
> to send a http GETAJAX request to http://www.site.com/page.html in 
> order to get the information corresponding to the new element modified 
> by the user.
> Actually the problem is adressed by sending a http GET to another 
> page, for example www.site.com/page_ajax.html. But may be it can be 
> useful to send a http GETAJAX to the page http://www.site.com/page.html.
> process. So an ajax_id can be added to the http GETAJAX to 
> differentiate the ajax requests.
>

---

From: "Poul-Henning Kamp" <[email-masked]>
Date: Tue, 22 May 2012 19:25:06 +0000

>neuter some of the rfc2616 heuristics.

Sorry about that, I mistook your message for a message on the
varnish support mailing list.

---

From: "Musatov, Martin - CW" <[email-masked]>
Date: Tue, 22 May 2012 19:34:27 +0000

Always attribute to kindness what can adequately be explained to competence

-----Original Message-----
From: Poul-Henning Kamp [mailto:[email-masked]] 
Sent: Tuesday, May 22, 2012 11:34 AM
To: Christian RIGONI
Cc: [email-masked]
Subject: Re: add GETAJAX verb/method in http protocol

In message <[email-masked]>, Christian RIGONI writes:

>to send a http GETAJAX request [...]

Varnish can handle pretty much any weird request, but you have to neuter some of the rfc2616 heuristics.

Before vcl_miss{} is called, the req.request is forced to "GET", you will have to undo that, but I think that is about it.

	sub vcl_recv {

	sub vcl_miss {

---

From: Amos Jeffries <[email-masked]>
Date: Thu, 24 May 2012 22:51:31 +1200

>> By working on html page developpement, I remarked that very often 
>> (but not always of course), ajax request correspond to information 
>> that are relative to an html page.
>> order to get the information corresponding to the new element 
>> modified by the user.
> wanting the response as JSON/XML), is that a reason that doesn't suit?

The other reason is that GETAJAX would be an unknown method from the 
point of view of all existing cache infrastructure. Sending such a 
method for a URL of an already cached page template will invalidate the 
URL and wipe out any cache benefits you gain from making it static page 
with AJAX.

AYJ