Memcached/JSONP

Peter Leonov gojpeg at gmail.com
Sun Dec 20 06:08:24 MSK 2009


On 20.12.2009, at 5:31, dylanz wrote:

> Yep, I think you got it ;)
> 
> So on the first request to this URI:
> http://example.com/blah/9999999.json?callback=ding1111111
> 
> ... we may set the following data in Memcached for that resource:
> key:     /blah/9999999.json
> value:  john: {age: 20, gender: 'male'}
> 
> The next request to the same resource may look like this:
> http://example.com/blah/9999999.json?callback=ding2222222
> 
> ... so since the $memcached_key will match, Nginx will want to respond with:
> john: {age: 20, gender: 'male'}
> 
> However, we really want to respond with the above value, but wrapped in the callback value from the request, like:
> ding2222222(john: {age: 20, gender: 'male')

If this url looks good for you
http://example.com/wrap.html?key=/blah/9999999.json&callback=ding1111111

please try to create wrap.html with the following content:
<!--# echo var="arg_callback" -->(<!--# include virtual="$arg_key" -->)
and do not forget to enable SSI in its location ;)

You can think about SSI as a small and efficient scripting language within nginx.

Good luck,
Peter.


More information about the nginx mailing list