Setting Cache-Control to Public in WebHandler does not work

S

Sebastian Paul

Hi,

the task is easy: I want to have the Cache-Control set to Public.

void IHttpHandler.ProcessRequest(HttpContext context)
{
const int maxAge = 10;
_context.Response.Cache.SetExpires(DateTime.Now.AddSeconds(maxAge));
_context.Response.Cache.SetMaxAge(new TimeSpan(0, 0, maxAge));
_context.Response.Cache.SetCacheability(HttpCacheability.Public);
_context.Response.Cache.SetLastModified(DateTime.Now);
_context.Response.Cache.SetValidUntilExpires(true);
...
}

Things work fine, output is actually cached by ASP.NET, the HTTP
header value of max-age counts down to zero until content expires.
Only the Cache-Control keeps being private. Why?? I explicitly set the
value to HttpCacheability.Public...

Thanks for any help.
Sebastian
 
S

Sebastian Paul

Now I noticed that the same applies to ASPX Pages. Fortunately, I had
a look on our production envirionment (IIS) - Cache-Control is
actually Public there!
It turns out that the ASP.NET Development Server (aka Cassini) always
sets to Private (as well as it only allows private connections). That
makes sense and is good, but one has to know it...

Kind regards, Sebastian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,740
Latest member
AdolphBig6

Latest Threads

Top