Tuesday 7 August 2007

Visual Studio 2005 ASP.NET Development Server (Cassini) and HttpCachePolicy

The ASP.NET Development Server (aka Cassini) included with Visual Studio 2005 (the default web server for new web projects) doesn't honour cache headers emitted using the HttpCachePolicy class.

Inspecting the response headers from a page running in Cassini reveals the Cache-Control header is set private despite instructions to make the response publically cacheable:

context.Response.Cache.SetExpires (DateTime.Now.AddSeconds (30));
context.Response.Cache.SetCacheability (HttpCacheability.Public);
context.Response.Cache.SetValidUntilExpires (true);
context.Response.Cache.VaryByHeaders ["Accept-Language"] = true;

Just as importantly, no Vary header is sent down the line.

By contrast, running the same page in IIS sets the Cache-Control header public and the Vary header is set to Accept-Language, as intended.

The ASP.NET Development Server is a great help--when it works; when it does stuff like this it really throws a spanner in the works.

No comments:

Post a Comment

Spam comments will be deleted

Note: only a member of this blog may post a comment.