Setting Cache-Control to Public in WebHandler does not work

Discussion in 'ASP .Net' started by Sebastian Paul, Oct 2, 2007.

  1. 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
     
    Sebastian Paul, Oct 2, 2007
    #1
    1. Advertising

  2. 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
     
    Sebastian Paul, Oct 10, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Charles A. Lackman
    Replies:
    1
    Views:
    1,401
    smith
    Dec 8, 2004
  2. SpamProof
    Replies:
    0
    Views:
    601
    SpamProof
    Oct 21, 2003
  3. Sam  Collett

    Execute WebHandler from another page

    Sam Collett, Dec 14, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    333
    Sam Collett
    Dec 14, 2006
  4. =?Utf-8?B?YmlsbCB0aWU=?=

    webHandler directive(?)

    =?Utf-8?B?YmlsbCB0aWU=?=, Mar 30, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    424
    =?Utf-8?B?YmlsbCB0aWU=?=
    Mar 30, 2007
  5. Ivonne Riedel

    general question asynchronous webhandler with pinvoke

    Ivonne Riedel, Jan 30, 2006, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    145
    Ivonne Riedel
    Jan 30, 2006
Loading...

Share This Page