For a quick and easy solution, you can use the HttpContext.Session
object to store a value like this:
int distance;
if(Session["distance"] == null)
{
distance = GetKilometers(vehicleId);
Session["distance"] = distance;
}
else
{
distance = Convert.ToInt32(Session["distance"]);
}
To make it even easier, you can abstract this into its own method.
EDIT
The above solution is good for a minimal amount of data. Given the fact that there will be a LOT of data being stored in your case, I see two possible scenarios:
The calculated data for a vehicle X is different for each user
Cache the calculated data in a separate table in the database with UserId (or SessionId), VehicleId, and CalculatedData.
The calculated data for vehicle X is the same for any user that needs vehicle X's data
Cache that calculated data in a column in the vehicle table in the database.
Either way, your call to the database should retrieve data for all vehicles that the user needs for the current request. Then store that data in a local variable that lives only for the current request. If you're going to cache data by session, you can use HttpContext.Session to store the SessionId and use that to retrieve the data from the database.