开发者

Why is my page not being cached?

This is just making me angry. I can't figure out why all the resources in my page are being requested EVERY single time.

E.g. my site.css returns the following headers (using fiddler):

HTTP/1.1 200 OK
Server: ASP.NET Development Server/9.0.0.0
Date: Mon, 29 Nov 2010 17:36:21 GMT
X-AspNet-Version: 2.0.50727
Content-Length: 9093
Cache-Control: public, max-age=2592000
Expires: Wed, 29 Dec 2010 17:36:21 GMT
Last-Modified: Mon, 08 Nov 2010 17:20:16 GMT
Content-Type: text/css
Connection: Close

But every time I hit refresh I see all the resources (css,js,images) getting re-requested. I have control over the headers returned for any and all of these resources, but I haven't figured it out yet.

I have even debugged my ASP.NET app and the HttpModule is definitely being asked for the resources again.

Can someone give me an idea of what to do?

EDIT: Ok, I removed must-revalidate, proxy-revalidate from the headers and that is getting me closer to where I want to be, now when I press back it still requests my css/js files when I press back.

Is there anything more I can do to avoid this开发者_JAVA百科?


The following links might be of help to you.

Differences in reload behavior between FF and IE

http://blog.httpwatch.com/2008/10/15/two-important-differences-between-firefox-and-ie-caching/

In a nutshell, your caching behavior is going to be determined by the headers and the browser you are using.

What browser are you using for testing? The back button is also handled differently.

Back Button (Browser Behavior)

And, finally, a breakdown of f5/ctrl f5, click, shift click, etc behavior between browsers: What requests do browsers' "F5" and "Ctrl + F5" refreshes generate?


If you are handling the requests in your own module - which seems to be the case - and the request contains an If-Modified-Since header, you can use that to determine whether to respond with a 200 and sending the whole resource again, or just send a 304 and skip sending the js/css/etc contents.

Other than that, expect browsers to re-query resources on hitting F5 / Refresh. It is just that you may skip sending the whole js/css/etc and return a 304 if everything is OK. Other than that, @Chris's answer covers pretty much everything else.

What are the request headers you see when you hit back?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜