When a test runs in the Synthetic Classic Portal, the browser cache is cleared after each test run.
To create a test that uses the browser cache, first consider how the cache is used:
Generally, browsers create a cache of the web pages you visit to load the page faster for subsequent visits to the page. But whether a browser uses the cache depends on the user's actions and the cache control HTTP headers.
To create a test that uses the cache or refreshes the target page, there are three possibilities:
- Visit the same page twice, the second time retrieving the page from the browser cache, and get the result of the second visit.
- Emulate pressing F5 to refresh the page.
- Emulate pressing Ctrl+F5 to refresh the page.
|Re-visit the page||Access the same URL again||location.replace(location.href)|
|Force Refresh||Press Ctrl+F5||location.reload(true)|
In Internet Explorer, Firefox, and Chrome, the page is cached when you first visit a web page. Then:
- If you re-visit the page, the browser reads the cache first, and then sends the requests only to those objects that don't have an Expire header or that have an Expire header but are expired.
- If you refresh this page with F5, the browser sends a request to all objects, but adds additional HTTP headers (such as If-Modified-Since) to check with the server to see if the object has expired. If the object has not been changed on the server side, the server replies with the response code 304: not modified.
- If you force-refresh the page with Ctrl + F5, the browser sends requests to all objects, with some additional HTTP headers (such as Cache-Control: no-cache), ignoring the local cache. Therefore, every object is loaded again.
This table summarizes browsers behaviors:
|Action Name||Send request to all HTTP objects||IE additional header||Firefox additional header|
|Force Refresh||Yes||Cache-Control: no-cache||Cache-Control: no-cache|
* The browser will read the cache, then only send requests to those objects that don't t have an Expire header or that have an Expire header but have expired.
** The XXXX in If-Modified-Since:XXXX means the expiration time of the cache content.
The attached scripts Re-Visit.gsl,F5-Refresh.gsl and CtrlF5-Refresh.gsl demonstrate how the local cache works and how to create a script with a local cache. Since the Browser Agent agent cleans the cache after each test run, the script needs to load the same page in Step 1 to generate the cache. That means you cannot create a one-step test to see the result for re-visit, refresh or force refresh.
The Repeat Visitor feature in the Windows Recorder is a solution for Re-visit. This feature is only available for the IE Agent. If you enable Repeat Visitor, it runs the same test twice in the same browser window, using the cached page for the second run; only the response time data for the second run is stored in the Synthetic Classic database.