You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

部署含新JavaScript文件的EAR包后函数未定义问题:IE11/Chrome默认缓存时长、自动清除机制及生产环境加载咨询

Hey, let's tackle your questions step by step since I've dealt with similar caching issues on JBoss deployments before:

1. Default cache duration for JavaScript files in IE11 and Chrome
  • Chrome: If your JBoss server doesn't send explicit Cache-Control or Expires headers, Chrome uses heuristic caching for static resources like JS. Typically, this means caching the file for a few hours to a full day, with the exact duration depending on the file's last modified timestamp.
  • IE11: It follows similar heuristic rules but tends to have a more conservative default—usually within 24 hours. Again, this only applies when the server doesn't specify cache headers.
    Critical note: These defaults aren't hard values. The server's response headers always take precedence over browser defaults.
2. Will old cached JS files auto-expire and load the new ones without manual clearing/refreshing?
  • Yes, but it depends on how the browser determines if the cached resource is "stale":
    • If your server sets explicit headers like Cache-Control: max-age=3600 (cache for 1 hour) or Expires: [specific timestamp], the browser will automatically check for updates once that time passes.
    • Without these headers, browsers use heuristic caching. Once the cached file exceeds the browser's default threshold, it sends an If-Modified-Since request to JBoss. If the file has been updated, JBoss returns a 200 with the new content; if not, it returns a 304 to use the cache.
  • The "works after half a day" behavior you're seeing is exactly this auto-expiration in action. But relying on default heuristics is unreliable—different browsers (and even different users) might have varying cache timelines, leading to inconsistent experiences.
3. Does this auto-loading mechanism work the same in production?
  • Absolutely—browser caching logic is environment-agnostic, so production will behave the same as QA. However, this creates a risk in production: users will get the new JS at different times as their individual caches expire, leading to a mixed state where some users have the new functionality and others don't.
  • A far better practice for JBoss deployments is to:
    1. Configure explicit cache headers for static resources (e.g., Cache-Control: public, max-age=31536000 for long-lived, versioned files).
    2. Add a version/hash suffix to your JS filenames (like app.7f9d2.js instead of app.js). This way, when you deploy a new version, the filename changes, and browsers will immediately load the new file without waiting for cache expiration.

内容的提问来源于stack exchange,提问作者Phani

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.30 05:22:40