Memcached/JSONP

Peter Leonov gojpeg at gmail.com
Sun Dec 20 02:33:32 MSK 2009


Hi, Dylan,

Nginx has a great SSI module. Try it to wrap like in this simple trick:

/wrap.jsonp?some_key_in_memcache

In wrap.jsonp:
window.processJSONP(<!--# include virtual="/memc/$args" -->)

And call this wraper instead of direct src.

Am thinking, it could work.

On 20.12.2009, at 0:08, "dylanz" <nginx-forum at nginx.us> wrote:

> Hello!
>
> We have an API which makes heavy use of JSONP.
> In context, that means the body of the response from our API must be  
> wrapped in a callback parameter that's passed in the same request.
>
> We currently store the JSON output from our API in Memcached, and on  
> subsequent requests, we jump into our application, pull the JSON  
> output out of Memcached, wrap the output in the callback parameter,  
> and return the response.  This works OK, but we'd much rather  
> utilize Nginx and its Memcached module.
>
> So, I was thinking it would be great if we could do the following.   
> We would store the JSON output from our API in Memcached, base on  
> the URI.  On subsequent requests, the key would be found via the  
> Memcached module, and the output wrapped in the current requests  
> callback parameter.  This way we wouldn't need to jump into our  
> application, and everything would be handled via Nginx.
>
> This would obviously require some customizations/extensions to the  
> Memcached module, and wanted to get some feedback to see if this  
> scenario was plausible, if there were better approaches, etc.
>
> Any suggestions, etc, would be greatly appreciated,
> Thanks!
> ==
> Dylan
>
> Posted at Nginx Forum: http://forum.nginx.org/read.php?2,31961,31961#msg-31961



More information about the nginx mailing list