In order to perform a good performance test on the HTTP protocol, there is something that you should know about it. Let’s start!
The Hypertext Transfer Protocol is an application-level protocol for distributed, hypermedia information systems. This is the foundation for data communication for the World Wide Web since 1990. It is a generic and stateless protocol which can be used for other purposes as well as using extensions of its request methods, error codes, and custom-headers.
The GET method is used to retrieve information from the server using a given URI. Requests using GET should only retrieve data. It should do any data manipulation or any write action.
A POST request is used to send data to the server. It creates data on the server side. It can upload textual information, as well as files of any other media types.
Put method changes the data stored on the server side with the uploaded content.
It removes all the current representations of the target data.
There is some important terminology when working with HTTP like Content-Type, Content-Encoding, Headers, etc. By using all of them, we can only create a complete request. Let’s deep dive into them.
HTTP custom-headers are additional information sent with the request or the response. It defines information about payload, client information and what’s expected from a server. According to that information, the server creates the response body.
Some request custom-header values are below:
Example: Some web apps might receive or send the response body as XML or JSON file according to the values set in the custom-header. So you need to set “Accept” attribute to “application/json” or “ application/xml”.
An HTTP cookie is a very small data sent from a web application. Cookies are stored on the user’s computer by the user’s web browser while the user is browsing. Cookies are the reliable mechanism for websites to remember stateful information. (How do you think e-commerce websites remember what items are in your art even after 3 days). Cookies have an expiration date or a max-age attribute. Those attributes define the last date the web app recognize your user. You may want to set domain and path attributes so that cookies are valid only under that scope. This is the trickiest part when you work with JMeter on web apps having authorization.
Caching is a technique that allows to store a copy of a given resource. When a web cache has a requested resource in its store, it returns the copy (cached response) instead of re-downloading from the server once again. This brings some benefits of course. A server doesn’t need to serve all clients itself as storing it helps distribute some resource. It improves performance by being closer to the client by using browser cache. It takes less time to transmit the resource. Cache has also some attributes like Cookies. Cache’s max-age attribute defines the last date an object is considered as fresh or rotten.
After understanding those basic structures, you can design and implement better performance tests with JMeter by using HTTP Sampler, HTTP Cache Manager, HTTP Header Manager, and HTTP Cookie Manager.
Check out Loadium blog to learn more about Load testing!