Jump to content

How to compress URLs sent to server?


NotionCommotion

Recommended Posts

I am making some AJAX GET requests which contain two large JSON arrays which only contain integers, and will be hitting the maximum URL size (at least for IE).  Any recommendations on how best to eliminate/increase this boundary?  My thoughts are:

 

  • Client side join the array to a string using periods, and then explode serverside.
  • Change from GET to POST or PUT.   Probably PUT since it is idempotent, right?  Note that I don't want to cache so maybe this is the best solution.
  • Use LZW compression or some other solution?
  • Any others?
Link to comment
Share on other sites

See Using HTTP Methods for RESTful Services

 

The idea behind PUT is that the request should be either creating or updating the entity specified by the URI with the data in the body. For example:

PUT /users/kicken.json HTTP/1.1
Host: example.com
Content-type: application/json

{"name":"kicken","skills":["php","javascript","html"]}
The server would write that json data to whatever entity.json is.

 

 

Since you're currently using GET the assumption is that you're just fetching data and the array's you are sending are for filtering. If so, GET is the proper verb but if you're exceeding size limitations then moving to POST is the next best option. In REST terms POST is used to create new resources but it's also commonly used as a generic catch-all for requests without a more appropriate verb available.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.