Jump to content

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
https://forums.phpfreaks.com/topic/306896-how-to-compress-urls-sent-to-server/
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.

Thanks kicken,  It took me two times to read and understand.  The first time I thought you were wrong.  The second time, I reverted and thought you were right.  I still think PUT "might" be more appropriate than POST, but think I should use POST if a de facto standard.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.