Speed up PHP with JSON and AJAX

javaScriptLogo

Hi,

So we decided to work on streamlining and speeding up StudioWeb’s basic functionality. When it comes to user perceptions of a web application’s speed, the most important thing to look at is the request/response cycle. But first, the most obvious thing you can do, is to just increase your server’s speed:

  • More RAM
  • More CPU
  • Faster disk drives
  • Empty disk drives – <50% full disk always move much faster.

… New servers are coming very soon to StudioWeb. In the meantime though, there are things you can do the application’s code itself.

AJAX with JSON

StudioWeb makes heavy use of AJAX to submit answers to the server for processing. So we decided to utilize JSON to send the data – rather than posting just a raw strings of text. What we get out of this, is a much faster response time from the users point of view.

To use JSON, you Typically use JavaScript

If you are sending post request via standard post and not AJAX, you can’t take advantage of JSON, since JSON is a function of JavaScript – meaning, it is all about creating JSON objects with JavaScript and the only way to use JavaScript in the request/response cycle, is to use AJAX … or specifically, the XMLHttpRequest() object.

… But now I am getting deep into nerd territory. All you need to take away is that using JSON to pass information to and from a server can speed up things a lot.

Stefan Mischook
killerPHP.com


This entry was posted on Monday, January 27th, 2014 at 11:39 pm and is filed under PHP Tips and Tricks. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

Comments are closed.

Created By Stefan Mischook  |  Top of page  go to top of page