Search code examples
.nethttpcachinghttpwebrequest

What is RequestCacheLevel.BypassCache internally?


The documentation on RequestCacheLevel.BypassCache doesn't explain much on the internal working of setting this with HttpWebRequest. Some questions I have on it:

  • What cache is this refering to?
  • Is this setting adding any cache control headers?
  • How does this compare with NoCacheNoStore & Reload which do set headers?
  • If I want to ensure (as much as possible from the client side) that the content does not come from cache is this the best option?

Solution

  • To answer my own question:

    • HttpWebRequest does make use of the IE cache and RequestCacheLevel.BypassCache is refering to that cache.
    • The setting is adding cache control headers
    • Compared to NoCacheNoStore both avoid the cache; however, BypassCache will load to the cache so if you do a future request it will be there. Reload does similar but the headers allow proxies to return from their cache whereas BypassCache tells proxies to ignore their cache too.
    • Yes, it is the best option ;)