Note that there are some explanatory texts on larger screens.

plurals
  1. POSetting optimum http caching headers and server params in ASP.Net MVC and IIS 7.5
    primarykey
    data
    text
    <p>I have an ASP.Net site (happens to be MVC, but that's not relevant here) with a few pages I'd like cached really well. </p> <p>Specifically I'd like to achieve:</p> <ol> <li>output cached on the server for 2 hours.</li> <li>if the file content on the server changes, that output cache should be flushed for that page</li> <li>cached in the browser for 10 minutes (i.e. don't even ask the server if it's that fresh)</li> <li>when the browser does make an actual subsequent request, I'd like it to use etags, so that the server can return a 304 if not modified.</li> </ol> <p>(note - time values above are indicative examples only)</p> <ul> <li>1) and 2) I can achieve by Response.Cache.SetCacheability(HttpCacheability.Server)</li> <li>I know 3) can be achieved by using max-age and cache-control:private</li> <li>I can emit etags with Response.Cache.SetETagFromFileDependencies();</li> </ul> <p>but I can't seem to get <em>all</em> of these things to work together. Here's what I have:</p> <pre><code> Response.Cache.SetCacheability(HttpCacheability.ServerAndPrivate); Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches); Response.Cache.SetETagFromFileDependencies(); Response.Cache.SetValidUntilExpires(true); Response.Cache.SetMaxAge(TimeSpan.FromSeconds(60 * 10)); </code></pre> <p>Is the scenario I want possible? In particular: </p> <ul> <li>can browsers do both 3) and 4) like that? When Firefox issues a new request after it expires in the local cache, it does indeed send the etag the server responded with before, but I get a 200 response. </li> <li>setting the variables like above, where would I set the duration of the output caching?</li> </ul> <p>Thanks for any tips!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload