Var
Prefer the var keyword when declaring local variables if the right hand side of the declaration makes the variable's type obvious.
StreamWriter sw = new StreamWriter(filename)
Should be:
var sw = new StreamWriter(filename)
Doing this makes it easier to change variable type later, and makes it more concise and easy to read for others.
Naming
Avoid using acronyms or shortened forms of words in variable, type and method names. By using the longer form, it is much clearer and easier for a maintenance programmer to understand.
StreamWriter writersw = new StreamWriter(filename)
Should be:
StreamWriter writer = new StreamWriter(filename)
Braces
Opening curly braces should be on their own line and, like dougajmcdonald suggests, the contents of the braces should be indented.
Structure
This method is a mess, it has four out parameters, and no return type!
private static void serializeToDisk(string key, CacheItemUpdateReason reason, out Object expensiveObject, out CacheDependency dependency, out DateTime absoluteExpiration, out TimeSpan slidingExpiration)
{
string filename = HttpContext.Current.Server.MapPath("settings.xml");
expensiveObject = instance;
dependency = new CacheDependency(filename);
absoluteExpiration = Cache.NoAbsoluteExpiration;
slidingExpiration = Cache.NoSlidingExpiration;
using (StreamWriter sw = new StreamWriter(filename))
{
serial.Serialize(sw, instance);
}
}
An out parameter is (unless there's a very good reason to have it) a strong code smell. Refactor to have a single type returned (most likely a bespoke class containing your out parameters), or split the method into four.
Secondly, in that function the parameter key appears to be doing nothing at all.
Validation
You don't validate any of your property setters. You should check, at the bare minimum, for null values, and anything else that could throw an exception and report it at the source.