Each virtual user (VU) maintains its own web cache as per the HTTP 1.1 specification.
When a script initiates a web request the caching behavior is as follows:
- If the requested URL is in the VU's cache then:
- If it is "fresh" (essentially not expired), set the cached page to be the current page and return immediately (no data is sent to the server).
- If it is not fresh, then add
If-Modified-Sinceheaders to the request. The request then becomes a conditional
GETrequest (i.e., the server returns
304 Not Modified, rather than
200 OKif the resource has not been altered). If the response is a
304 Not Modified, merge the returned data with the cached data to form a full response.
- If the URL is not in the cache, then add it.
By default, only the page content of certain mime types is both cached and stored. The default list is:
Thus any resource with a
Content-Type header that starts with any of these words is cached and stored. So, content for
text/xml, etc. is all stored when
text is in the list of cached content types. This original content is then available to the virtual user. This list can be amended using the API, see
For some content types it does not make sense to store the actual content. For example, "image" URLs are cached but their content is not stored. In most cases, a virtual user is not interested in the content of an image.
Pre-populating the Virtual User's Cache
A VU's Web cache can be pre-populated using the API, specifically the class