As you know, gmail vfolders are basically database queries on the data. This allows for a very powerful and flexible mail viewing enviroment. Because the data (email messages) doesn't really change, it is often redundant to be running the same queries all the time on the same data.
To overcome this redundancy, Gmail uses something called a 'matched index' (MI). An MI value is associated with every message and it records what vfolders that message 'matches', that is, what queries will include that message in their result.
When new messages are downloaded, they are tested on every vfolder query, and the MI value is adjusted accordingly.
This way whenever you view a mailbox, you are not actually running the vfolder query, but simply doing doing a query based on the MI values.
Because vfolder queries can be very complex, they can be somewhat slow. But with the MI you can access any query in a very short amount of time.
The downside to this is whenever you add, delete, or modify a vfolder, you will need to do two things: (1) Tell Gmail to update it's matched index structure. (2) Tell Gmail to go and recreate all the MI's for each message.
Luckily this is quite easy and Gmail almost does it all for you. In practice, users end up accessing email 99.9% of the time and only changing vfolders 0.1% of the time. So using caching is not as awful as it sounds, and the speed benefits are excellent.