lloyd / connect-select

Server side filtering of JSON responses using JSONSelect
ISC License
33 stars 1 forks source link

HTTP header support #1

Open lloyd opened 13 years ago

lloyd commented 13 years ago

What if selectors were provided in HTTP headers? So a request could include:

X-JSONSelect-Filter: .foo > .bar

and if a server is capable of filtering the response, he includes a response header:

X-JSONSelect-Filtered: true

If the server doesn't know what the frak you're talking about, he just ignores you.

One thing I really like about this arrangement is you can then build efficient generic support into client libraries. They can send the filter and if the server doesn't support filtering then they can do client side filtering. Thinking like a jquery plugin or extension might be a fun way to explore this notion.

I'm uncertain whether this would break popular cache implementations though, because content varies based on the contents of the URL and the X header. Content with the same URL has different cache-able output.

lloyd commented 13 years ago

Use Vary: headers! http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.44

Even though some popular cache implementations don't dig said headers: http://wiki.nginx.org/NginxHttpProxyModule#proxy_cache_key

tj commented 13 years ago

+1

bramswenson commented 12 years ago

I'm up for trying to implement this with further discussion on how you guys would like to see it work. Nginx is pretty popular, and I know lots of my apps rely heavily on caching and CDN, so making sure this works with these things would be paramount. I would also ensure that cache interoperation is documented in the README upon such a change.