NotionCommotion Posted March 21, 2018 Share Posted March 21, 2018 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? Quote Link to comment Share on other sites More sharing options...
kicken Posted March 21, 2018 Share Posted March 21, 2018 I would just change to POST. PUT doesn't seem appropriate to me unless your creating something on the server using those numbers. 1 Quote Link to comment Share on other sites More sharing options...
requinix Posted March 21, 2018 Share Posted March 21, 2018 Yeah, POST doesn't have to be just for modifying resources. It's perfectly fine to use it for read-only operations that involve sending lots of data. Quote Link to comment Share on other sites More sharing options...
NotionCommotion Posted March 22, 2018 Author Share Posted March 22, 2018 Thanks both of you, POST is fine. Just curious, what is wrong with PUT? I am using slim which supports and so does jquery Ajax. If no PUT here, should I also not use PUT when updating an existing record? Quote Link to comment Share on other sites More sharing options...
kicken Posted March 22, 2018 Share Posted March 22, 2018 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. Quote Link to comment Share on other sites More sharing options...
NotionCommotion Posted March 22, 2018 Author Share Posted March 22, 2018 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.