0

Simple question really, but not one I am able to find clear guidance on. I'm writing web services that support JSONP responses (based on specification of a callback query param), and would like to provide support for compression.

I raised another question a while back about a possible bug in ServiceStack, but before providing a fix for it, I'm looking for guidance on whether I should be in the first place?

Community
  • 1
  • 1
SteveChapman
  • 3,051
  • 1
  • 22
  • 37

1 Answers1

0

Yes. Technically JSONP is javascript, not JSON. I.e. it should have application/javascript mimetype. And, just like any other JS resource a web page might request (e.g. a static foo.js file), it can be compressed.

Community
  • 1
  • 1
broofa
  • 37,461
  • 11
  • 73
  • 73
  • Thanks for the clarification. Kind of confirms my thinking that I need to fix some bugs (see other linked question above). Would you expect a compressed response based on the definition of an `Accept-Encoding: gzip,deflate,sdch` header? Quick test in Fiddler suggests that's how a `foo.js` `application/javascript` request works. – SteveChapman Dec 04 '13 at 04:02
  • Yeah, it should be handled just like any compressed request-response. The compression negotiation is taking place as part of the HTTP request-response header negotiation, which is more or less independent of the type of data being transported. JS, CSS, html... whatever - if you look at how these kinds of files are transported (and compressed), the headers will all look similar. – broofa Dec 04 '13 at 17:56