On Dec 6, 2013, at 3:09 PM, Jean Baptiste Favre <[email protected]> wrote:
> Hello, > > I need to cache some json API response. > The API sent only indented json. > > To reduce network trafic and optimize cache, I need to be able to remove > space and new lines. The LinkedIn folks wrote a PageSpeed plugin. I think it can do this, <https://github.com/linkedin/ats_pagespeed>. > I'm considering to use gzip. Problem is, this would invalidate current > cache which is not an option. But, when ATS will revalidate URL, it'll > use gzip and both gziped & normal content will be cache. Would is really get invalidated? If the client would accept compressed content and there is already an uncompressed variant in the cache, would the gzip plugin be able to send a compressed version from cache? > In the meantime, I'm trying to implement a plugin to handle json > transformation. > From what I understand, I need to write a buffered transformation plugin > to make sure I got the whole json. So I studied bnull_tranform plugin > and read the documentation. > > From what I read, I have to add my code into handle_output function. > I need to use data->output_reader to get content into a char, transform > it with json-c library function. > Char result will be added into a new TSIOBuffer. > Once done, I'll be able to write it into output_conn. > > Am I right ? > > My problem is that I don't know how to get data->output_reader content > as char. > As far as I've seen, output_reader is a TSIOBufferReader structure and I > can not find any definition of it. > > As you may have noticed, I'm quite a newbie in C, but any advice will be > apreciated. I haven't written a transformation, but it seems they can be tricky. As Daniel Morilha pointed out on a different thread, the LinkedIn C++ API is a good additional reference for transformation code, <https://github.com/linkedin/atscppapi/blob/master/src/TransformationPlugin.cc> James
