开发者

How to enable IIS cache in a such a way that browsers won't even check if the resource has changed?

开发者 https://www.devze.com 2023-01-22 19:06 出处:网络
We enabled static resource caching in our ASP.NET application like this: <system.webServer> <staticContent>

We enabled static resource caching in our ASP.NET application like this:

<system.webServer>
    <staticContent>
      <clientCache cacheControlMode="UseExpires" httpExpires="Thu, 29 Oct 2020 00:00:00 GMT" />
    </staticContent>
  </system.webServer>

Using a sniffer, we can confirm that the Expires tag is actually being 开发者_Go百科placed on the respose's header.

However, the browsers insist on requesting the server to check whether the resource has changed or not. The server returns a not modified code (304). This is, indeed, a very light weight request but we're highly concerned about performance so we'd like to save theses requests.

How can I tell the brosers they shouldn't even request the server?

PS: ETags are properly being sent to the client. I thought that if I removed them the browsers could somehow stop requesting the server but I couldn't remove these tags on IIS 7. I don't know if it would help anyway.


Something's not adding up, what you've described should be sufficient for eliminating the If-Modified-Since/304 behavior. Can you include all response headers, so we can have a closer look?

Also, note that hitting 'Refresh' would cause what you've described - what you should be testing is an actual link to the page in question.

FYI, I posted a similar question a while ago (1), except that I was seeing the opposite: the normal If-None-Match/304 interaction was optimized away by the browser (in the same session).

(1) ETags, IIS7, Kernel Cache Policy (enableKernelCache)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号