Are WordPress widgets cached?

Ok, seems that the problem is not related to the cache. But to the action execution order. If I update the value inside a page template (or inside a shortcode, that’s why I started my tests) the update fires after the render of the widget.

Solution: update the value inside an action. In this example you can use the 'wp' action:

function test() {
    if ( is_page( 749 ) ) {
        update_option( 'custom_check', 'a' );
    } elseif ( is_page( 800 ) ) {
        update_option( 'custom_check', 'b' );
    }
}

add_action( 'wp', 'test' );