Clean Out VSWebCache

Posted on 2006-02-16 14:17  A.Z  阅读(557)  评论(0编辑  收藏  举报

by Don Kiely

January 2003 Issue

Technology Toolbox: ASP.NET

Level: Intermediate

If you spelunk around your ASP.NET development machine—particularly if you're a conscientious geek who monitors and cleans out your Documents and Settings directory regularly—you've probably found something such as C:\Documents and Settings\username\VSWebCache. You'll find subdirectories in it named for each server on which you've worked on an ASP.NET app while using this machine. In each of those subdirectories, you'll find other subdirectories for each project, along with other detritus. If you work with ASP.NET a lot, you're likely to find many megabytes of miscellaneous files, hundreds of other subdirectories, and plenty of embarrassing junk from your first efforts writing .NET code you thought you'd long since cleaned off your machine. I'll explain what VSWebCache is, why all that junk is there, and whether it's safe to blow it away.

VSWebCache's primary purpose is to support offline development. Suppose you're developing an app that'll be on the server at www.example.com. You can create the application locally on your development machine—perhaps a laptop you're using on an international flight—and later synchronize the work you've done offline with the server. All your build files and any support files you've added to the VS.NET project are saved locally in C:\Documents and Settings\username\VSWebCache\example.com\MyWebApp. It includes hidden subdirectories such as _vti_cnf and _vti_pvt. According to the ASP.NET documentation, files are pushed to VSWebCache when you first work offline. Then they're pushed to the server when you go back online or synchronize the files explicitly. It works fairly similarly to how it was supposed to work (but didn't) in Visual InterDev 6.0.

So VSWebCache is usually a good thing, because it lets you store remote files locally so you can work on and run your site while you're offline. But you might never work on a remote site offline. I always build my sites on localhost, keep the files in Visual SourceSafe on a machine accessible to both my development machine and the server, and then update the files to the server directly from SourceSafe. I never use offline mode, and until I researched this tip, I didn't even know where to turn it on in VS.NET. (You select Project | Web Project | Work Offline from the VS.NET main menu.)