Synthetic Classic has reached end of support and is no longer available. Existing Synthetic Classic customers have been upgraded to the all-in-one Dynatrace software intelligence platform.

Partial file downloads

In many cases, the website we are testing will have some files that greatly exceed the default byte limits for Synthetic Classic tests. In those cases, we may be able to work around the problem by doing a partial file download. There are a couple of different ways we could accomplish this, depending on the need.

The easiest way is to use a range header for the script. We can insert this in the Headers tab for the script. The name of the header is range, and the value is bytes=0-100000, or whatever number is needed to bring the value within limits. In this example, we are limiting all files to 100 KB in size.

The downside to using the above method is that all files are limited to whatever size you specify. In some cases, you may only want to limit image files, but allow other files, such as large .js or .css files. In these cases, it is necessary to use a Custom action with an event hook that limits the size of just the files you want. The code for this, which uses control as the target window, is below.

In the example code, we are adding the hook to any file that contains jpg. We are then limiting each jpg file to 50,000 bytes (50 KB) in size, keeping the file sizes very small. This allows other large files to be downloaded in full, while restricting jpg image files only. This is generally very useful on a product listing page that may show 50-or more items and uses larger image files on the page.

var send = new AddEventHookCommand({
"eventType": "sendingRequest",
"name": "setCustomCookie",
"handler":"if(request.getUrl().indexOf('jpg') != -1){ var headers = request.getHeaders(); headers.add('range', 'bytes=0-50000');}"