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

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top