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!

Trang web này sẽ có chức năng hạn chế trong khi chúng tôi trải qua bảo trì để cải thiện trải nghiệm của bạn. Nếu một bài viết không giải quyết được vấn đề của bạn và bạn muốn đặt câu hỏi, chúng tôi có cộng đồng hỗ trợ của chúng tôi đang chờ để giúp bạn tại @FirefoxSupport trên Twitter và /r/firefox trên Reddit.

Tìm kiếm hỗ trợ

Tránh các lừa đảo về hỗ trợ. Chúng tôi sẽ không bao giờ yêu cầu bạn gọi hoặc nhắn tin đến số điện thoại hoặc chia sẻ thông tin cá nhân. Vui lòng báo cáo hoạt động đáng ngờ bằng cách sử dụng tùy chọn "Báo cáo lạm dụng".

Tìm hiểu thêm

Firefox tends to evict from cache JavaScript with size over 15MB

  • 6 trả lời
  • 1 gặp vấn đề này
  • 1 lượt xem
  • Trả lời mới nhất được viết bởi Peter Kolínek

more options

We are using web application that uses JavaScript batch files, where one of them exceeded size of 15MB. Since then Firefox seems to evict the file from cache and always load it from the server also excluding If-Modified-Since header. When the file size is decreased to former size ( around 12MB ), caching works again as expected: file is either served from Firefox cache or If-Modified-Since header is sent in request to verify if server file changed. When I checked difference between files server, there was nothing changed except file size and content ( i.e. there is no dynamic changing of file, cache headers stay the same, ... ).

Is there some configuration setting or hard-coded limit which forces Firefox to evict larger files from cache and enforce their reloading?

Here is the list of selected response headers on mentioned file:

X-XSS-Protection: 1; mode=block X-Content-Type-Options: nosniff X-Frame-Options: SAMEORIGIN Content-Security-Policy: frame-ancestors 'self' Expires: Tue, 22 Sep 2020 07:43:13 GMT Cache-Control: max-age=31536000 Cache-Control: public Last-Modified: Thu, 01 Jan 1970 00:00:00 GMT ETag: "0" Content-Type: application/javascript;charset=UTF-8 Keep-Alive: timeout=5, max=100 Connection: Keep-Alive Transfer-Encoding: chunked

Thanks for any hints.

We are using web application that uses JavaScript batch files, where one of them exceeded size of 15MB. Since then Firefox seems to evict the file from cache and always load it from the server also excluding If-Modified-Since header. When the file size is decreased to former size ( around 12MB ), caching works again as expected: file is either served from Firefox cache or If-Modified-Since header is sent in request to verify if server file changed. When I checked difference between files server, there was nothing changed except file size and content ( i.e. there is no dynamic changing of file, cache headers stay the same, ... ). Is there some configuration setting or hard-coded limit which forces Firefox to evict larger files from cache and enforce their reloading? Here is the list of selected response headers on mentioned file: X-XSS-Protection: 1; mode=block X-Content-Type-Options: nosniff X-Frame-Options: SAMEORIGIN Content-Security-Policy: frame-ancestors 'self' Expires: Tue, 22 Sep 2020 07:43:13 GMT Cache-Control: max-age=31536000 Cache-Control: public Last-Modified: Thu, 01 Jan 1970 00:00:00 GMT ETag: "0" Content-Type: application/javascript;charset=UTF-8 Keep-Alive: timeout=5, max=100 Connection: Keep-Alive Transfer-Encoding: chunked Thanks for any hints.

Giải pháp được chọn

In the end it seemed that issue has been present only in Firefox 60 ESR branch. Newest Firefox releases do not have this issue.

Đọc câu trả lời này trong ngữ cảnh 👍 0

Tất cả các câu trả lời (6)

more options

Firefox can send both a request to load content from the cache and also send a request to the server. Which response arrives first is used. This is called a 'racing' feature (RCWN: Race Cache With Network). If you have a slower hard drive then in some cases the server might respond quicker and send a partial file. The about:networking#rcwn page shows the current RCWN stats.

The Network Monitor shows a 'raced' value in the transfer column. There is a network.http.rcwn pref (network.http.rcwn.enabled) that controls this feature, so you can test whether your issue is about RCWN or something different.

Được chỉnh sửa bởi cor-el vào

more options

You may have found this preference --

browser.cache.disk.max_entry_size

-- with a default value of 50MB (51,200 KB). That seems large enough for your application's needs.

You can review the comments in the source code to learn more about the user-configurable parameters and some of Firefox's behaviors. Other behaviors might not be as clearly documented:

https://dxr.mozilla.org/mozilla-release/source/modules/libpref/init/all.js#31

more options

cor-el said

... The Network Monitor shows a 'raced' value in the transfer column. There is a network.http.rcwn pref (network.http.rcwn.enabled) that controls this feature, so you can test whether your issue is about RCWN or something different.

Thank you cor-el for info about this feature, but unfortunately it seems not to be the cause. When I've disabled rcwn, caching was still not used for 15MB file.

jscher2000 said

You may have found this preference -- browser.cache.disk.max_entry_size -- with a default value of 50MB (51,200 KB). That seems large enough for your application's needs. You can review the comments in the source code to learn more about the user-configurable parameters and some of Firefox's behaviors. Other behaviors might not be as clearly documented: https://dxr.mozilla.org/mozilla-release/source/modules/libpref/init/all.js#31

Yes, I've checked those. Just to be sure, I've tried to increase the caching limit preferences to 10 times its default size, also disabled disk smart cache size and extended its limit to a few gigs, but it still did not help.

What I noticed also is that, when I completely clear Firefox cache, the 15MB file is cached and is being used from cache for a while. It is also shown in about:cache disk stats that the file is there and usage count increases on page reloads. But after a short time period ( few page reloads ) the file is being transferred from network again, despite I can still see it in about:cache listing - just usage count is not increasing of course. When hitting CTRL+F5 on the page, I can see new refreshed entry in about:config with usage count one or a few times, but then again after a while file is being requested from network.

more options

Did you check in the Network Monitor whether the RCWN feature might be causing Firefox not to use the disk cache like I posted above?

more options

I checked the Network Monitor regularly, but never seen RCWN feature kick in. Is it marked by 'raced' string in Transfer column? In Transfer I always saw either file size or 'cached' string.

more options

Giải pháp được chọn

In the end it seemed that issue has been present only in Firefox 60 ESR branch. Newest Firefox releases do not have this issue.