Share this page

# web_load_cache

Miscellaneous Functions

Load the Vuser cache from a file.

    int web_load_cache( const char *Name, const char *fileName, LAST );

Argument | Description
--- | ---
Name | The label of the step in the Graphical Vuser script. Also used as the transaction name for automatic transactions.
fileName | The full pathname of the file to store the cache.
LAST | A marker that indicates the end of the argument list.

## Return Values

This function returns LR_PASS (0) on success, and LR_FAIL (1) on failure.

## Parameterization

All string arguments (char type) can be parameterized using standard parameterization.

## General Information

web_load_cache restores the browser cache from a file. It is used together with web_dump_cache to implement Vuser persistent caching. The script always runs with the same initial cache.

The purpose is to capture the browser cache once, while running the script manually. Then the same cache can be used repeatedly in tests. Using Vuser persistent caching improves CPU usage on the application and database servers.

After recording the script, add web_load_cache at the beginning and web_dump_cache at the end of either the Action or vuser_end section, as appropriate to your test. Run the script once with the web_load_cache call commented out. Then uncomment the web_load_cache call and comment out the web_dump_cache call. The result is that on each run the cache you created is reloaded.

The filename path must point to the file saved with web_dump_cache. It is possible, however, to use a relative path where an absolute path was used to save, or an absolute path where a relative was used to save.

File names can be parameterized, so that different Virtual Users or different iterations use different files. For example, "FileName=Iteration{param}.cache"

Note: If the script is not developed on the machine that will be running the tests, ensure that the cache files are accessible to the host at the path given in fileName.

## Example

In this example the Vuser logs on to a system and views her paycheck. The script is run once by the test developer with the web_load_cache call commented out, and the web_dump_cache call and the web_add_cookie calls uncommented. This creates the files to be used in the actual testing.

After the files are created, the web_load_cache call is uncommented, and the web_dump_cache call and the web_add_cookie calls are commented. On subsequent runs, the cache files are loaded before running the business process.

Copy code

    Action()
    {
    /* Initially used to create the Vuser environment:
        web_add_cookie("SignOnDefault=; domain=pbntas05; path=/");
        web_add_cookie("http%3a%2f%2fpbntas05%3a8250%2fpsp%2fps%2femployee%2fhrms%2frefresh=list:|; domain=pbntas05; path=/");
        web_add_cookie("storedCookieCheck=true; domain=pbntas05; path=/");
    End setup functions.
    */
    // Get the previously created cache

    web_load_cache("ActionLoad",
        "FileName=c:\\temp\\{VuserName}paycheck",
        LAST );

    /* From here down is the business process for which
        we want to use a persistent cache */

    web_browser("signon.html",
        DESCRIPTION,
        ACTION,
        "Navigate=http://myserver:8200/ps/signon.html",
        LAST );

    web_edit_field("userid",
        "Snapshot=t1.inf",
        DESCRIPTION,
        "Type=text",
        "Name=userid",
        ACTION,
        "SetValue={VuserName}",
        LAST );

    web_edit_field("pwd",
        "Snapshot=t2.inf",
        DESCRIPTION,
        "Type=password",
        "Name=pwd",
        ACTION,
        "SetValue=HCRUSA_KU0007",
        LAST );

    lr_start_transaction("login");

    web_button("Sign In",
        "Snapshot=t3.inf",
        DESCRIPTION,
        "Type=submit",
        "Tag=INPUT",
        "Value=Sign In",
        LAST );

    lr_end_transaction("login", LR_AUTO);

    web_image_link("CO_EMPLOYEE_SELF_SERVICE",
        "Snapshot=t4.inf",
        DESCRIPTION,
        "Alt=",
        "Name=CO_EMPLOYEE_SELF_SERVICE",
        "Ordinal=1",
        LAST );

    web_text_link("Payroll and Compensation",
        "Snapshot=t5.inf",
        DESCRIPTION,
        "Text=Payroll and Compensation",
        "Ordinal=1",
        LAST );

    web_text_link("View Paycheck",
        "Snapshot=t6.inf",
        DESCRIPTION,
        "Text=View Paycheck",
        "Ordinal=1",
        LAST );

    web_text_link("Sign out",
        "Snapshot=t7.inf",
        DESCRIPTION,
        "Text=Sign out",
        "FrameName=UniversalHeader",
        LAST );

    web_browser("browser",
        "Snapshot=t8.inf",
        DESCRIPTION,
        ACTION,
        "Sync",
        LAST );

    /* This command was used once to create the cache files, then
        commented out for the actually load testing */

    /*    web_dump_cache("paycheckcache",
            "FileName=c:\\temp\\{VuserName}paycheck",
            "Replace=yes", LAST );        */

    return 0;
    }

Tips to improve your search results... VuGen Function Reference Version 26.1-26.3 Function Reference 26.1-26.3 All View Local Help Center View Online Help Center Version: