A common question we are asked is how we deal with "new" vs. "return" users in a load test. Web browsers cache content and store cookies, which impacts the pattern and content of requests that are sent to the web server.

Load test scenarios have a "Percentage of new users" property that you can use to control this.

When a load test starts, the load test engine creates a queue of user profiles the size of the maximum load in the load test.

When a new vuser is started due to an increase in load, we use a random number and the "Percentage of new users" property to determine if the user is a "new user" or a "return user". New users have an empty cache and no cookies. Return users' cache and cookie store are built up as the test runs. If the user is a return user, the user is picked off the user queue, and the user's cookie and browser cache are used in the web test.

Each user has a unique id, which is available in the web test WebTest.Context.WebTestUserId property. A user's cookie collection is available in the WebTest.Context.CookieContainer property. Unfortunately we do not give programmatic access to the browser cache in the same way. The WebTest.Context.IsNewUser property does indicates if a user is a new user or return user.

User id's are scoped per agent, so each agent uses the same set of user ids. The unique agent id is in the WebTest.Context.AgentId property.