Join the AMA (Ask Me Anything) with the Firefox leadership team to celebrate Firefox 20th anniversary and discuss Firefox’s future on Mozilla Connect. Mark your calendar on Thursday, November 14, 18:00 - 20:00 UTC!

본 사이트는 여러분의 사용자 경험을 개선하기 위해 유지 보수를 진행하는 동안 기능이 제한됩니다. 도움말로 문제가 해결되지 않고 질문을 하고 싶다면 Twitter의 @FirefoxSupport 및 Reddit의 /r/firefox 채널을 활용하세요.

Mozilla 도움말 검색

고객 지원 사기를 피하세요. 저희는 여러분께 절대로 전화를 걸거나 문자를 보내거나 개인 정보를 공유하도록 요청하지 않습니다. "악용 사례 신고"옵션을 사용하여 의심스러운 활동을 신고해 주세요.

자세히 살펴보기

Firefox does not use cache on first load and reload

  • 8 답장
  • 2 이 문제를 만남
  • 1 보기
  • 최종 답변자: knorretje

more options

My webserver has a lot of images which will never change. So, I set Expires month forward in such cases:

Expires: Thu, 26 Jan 2012 02:01:25 GMT

Cache-control: public

Enough for IE 9, my server is not disturbed. But for FF8 and FF9 in following two scenarios my settings are ignored:

1) Close browser. Open browser, look at about:cache - all my files are on place. Open my page - server receives requests for all cached files. And nothing in request allowing server to detect that cache exists.

2) Press Reload button or F5. Again all cached files required. But now requests have Cache-Control: max-age=0 So, server has some idea about situation and probably can respond with 304.

Only 3) works as I proposed: after 1), open page once more - in the same or another tab. In this case, server receives only requests for files with restricted caching.

Current workaround: I add Last-Modified to response. In this case, I receive If-Modified-Since and can respond with 304. But I have hundreds of small images, so bandwidth for 304 is almost same as for 200 with complete file.

Browser cache settings - all defaults. I use numeric server addresses in current test environment like http://192.168.47.130:27374

I experimented with different modifications of Cache-Control response - without success.

And additional question - how can I make a line break in this editor? If I make a line break and empty line, I get line break and empty line. But if I make a simple line break, I get nothing in resulting text.

My webserver has a lot of images which will never change. So, I set Expires month forward in such cases: Expires: Thu, 26 Jan 2012 02:01:25 GMT Cache-control: public Enough for IE 9, my server is not disturbed. But for FF8 and FF9 in following two scenarios my settings are ignored: 1) Close browser. Open browser, look at about:cache - all my files are on place. Open my page - server receives requests for all cached files. And nothing in request allowing server to detect that cache exists. 2) Press Reload button or F5. Again all cached files required. But now requests have Cache-Control: max-age=0 So, server has some idea about situation and probably can respond with 304. Only 3) works as I proposed: after 1), open page once more - in the same or another tab. In this case, server receives only requests for files with restricted caching. Current workaround: I add Last-Modified to response. In this case, I receive If-Modified-Since and can respond with 304. But I have hundreds of small images, so bandwidth for 304 is almost same as for 200 with complete file. Browser cache settings - all defaults. I use numeric server addresses in current test environment like http://192.168.47.130:27374 I experimented with different modifications of Cache-Control response - without success. And additional question - how can I make a line break in this editor? If I make a line break and empty line, I get line break and empty line. But if I make a simple line break, I get nothing in resulting text.

글쓴이 mahris 수정일시

모든 댓글 (8)

more options

A good place to ask advice about web development is at the mozillaZine Web Development/Standards Evangelism forum.

The helpers at that forum are more knowledgeable about web development issues.
You need to register at the mozillaZine forum site in order to post at that forum.

more options

If you press F5 Firefox will try to do a revalidation request.
If you press Ctrl+F5 Firefox will try to do an end-to-end load.
In these cases the loading behavior of Firefox is determined by the loadflags and not by the headers. So it is built-in like this.
There is a preference for loading behavior but it is only used for normal loads.
If you want to reduce the number of 304s that you have to send you can think about using "spriting". This means that you send big pictures and show little parts of it at the clientside using CSS.


To make a linebreak in the editor of the forum you can type a html break element. "< b r >" without the spaces.
https://support.mozilla.com/en-US/kb/markup-chart

more options

Maybe, you are right and F5 acts as designed. There is no difference in request count for F5 and Ctrl+F5, the only difference - F5 requests contain If-Modified-Since, Ctrl+F5 do not. I think that IE interpretation is more correct - it's F5 does not send requests for non-expired cache.

And what do you think about my first scenario - close browser, open browser, enter address? Again FF sends requests for all cached items.

more options

I'm not sure what is going on in the first scenario. You can try to make a http log with Firefox, then Firefox will tell why it's using the cache or not. Unfortunately, this logging is very buggy for me on Vista so most times I am not able to get some decent information from it. Maybe you have more luck.
https://developer.mozilla.org/en/HTTP_Logging
In Firefox loading URIs is a bit complex. Firefox has nineteen loadtypes, and each loadtype sets different loadflags. That makes it difficult to predict the loading behavior without studying the source-code.

more options

You can also use the Live HTTP extension to see which headers are send to the server.

more options

Thank you, knorretje. Had no problems with logging on 2003. Lot of lines, but I propose that critical part
0[220f140]: nsHttpChannel::OnCacheEntryAvailable [this=3f6f400 entry=5236740 access=3 status=0]
0[220f140]: nsHttpChannel::Connect [this=3f6f400]
0[220f140]: nsHTTPChannel::CheckCache enter [this=3f6f400 entry=5236740 access=3]
0[220f140]: nsHttpResponseHead::Parse [this=6b113c0]
0[220f140]: nsHttpResponseHead::ParseVersion [version=HTTP/1.1 200 OK]
0[220f140]: Have status line [version=11 status=200 statusText=OK]
0[220f140]: ParseContentType [type=image/gif]
0[220f140]: nsHttpResponseHead::MustValidate ??
0[220f140]: no mandatory validation requirement
0[220f140]: Not validating based on expiration time
0[220f140]: nsHTTPChannel::CheckCache exit [this=3f6f400 doValidation=1]

As I understand, all partial checks say that cache is good. But ending doValidation=1, probably, means that request will be sent. Do not see any reason.

more options

Thank you, cor-el. As it is my server, I see all headers it receives. No need in Live HTTP.

more options

Hello mahris,
You are right, doValidation=1 means a request will be send.
"Not validating based on expiration time" means that the cache is good and doValidation is zero. On line later doValidation suddenly is one and the cache is not good anymore. If I look on MXR I can find two possible reasons:

  • A problem with the If-Match header (2660)
  • Not trusting the cache because it was filled in a previous session (2672)

http://mxr.mozilla.org/mozilla-beta/source/netwerk/protocol/http/nsHttpChannel.cpp#2650