apolloconfig / apollo

Apollo is a reliable configuration management system suitable for microservice configuration management scenarios.
https://www.apolloconfig.com
Apache License 2.0
29.08k stars 10.2k forks source link

升级到2.2.0之后强制刷新浏览器,清除js缓存才能看到审计入口 #5057

Closed luger1990 closed 9 months ago

luger1990 commented 9 months ago

升级到2.2.0之后强制刷新浏览器,清除js缓存才能看到审计入口。 后续打包的时候可以考虑给js加个版本号之类的。

dosubot[bot] commented 9 months ago

🤖

Hi @luger1990,

Nice to meet you! I'm Dosu, an automated assistant here to help you with issues, answer questions, and streamline the overall Apollo contribution process. While we're waiting for a human maintainer, feel free to ask me any questions you might have. I'm here to help!🙂

您的建议非常好,为JS文件添加版本号可以避免强制刷新浏览器和清除JS缓存才能看到审计入口的问题。这个改变需要在Apollo项目的构建过程中实现,而不是在JavaScript文件本身。

构建过程可能由Webpack或Gulp等工具管理,需要配置它们将版本号或哈希值附加到每个JS文件的文件名上。这样可以确保每个新版本的文件都有一个唯一的名称,使浏览器下载新文件而不是使用缓存版本。

不幸的是,由于我无法访问Apollo项目的构建配置,我无法提供具体的代码解决方案。但是,以下是一个如何配置Webpack以将哈希添加到文件名的一般示例:

module.exports = {
  //...
  output: {
    filename: '[name].[contenthash].js',
  },
};

在这个例子中,[name]将被替换为原始文件名,[contenthash]将被替换为文件内容的哈希。这将确保文件内容更改时文件名也会更改,从而使浏览器下载新版本。

请参阅您的特定构建工具的文档,以获取如何实现此更改的更多信息。

至于Apollo项目的当前构建过程,它是由Maven管理的,如pom.xml文件所示。构建过程包括编译、测试、打包、安装、部署、代码质量检查、版本控制、签名、组装和资源过滤等步骤。

我在Apollo项目的仓库中没有找到使用Webpack或Gulp等JavaScript构建工具的证据,这些工具可以配置为将版本号或哈希添加到每个JS文件的文件名。可能需要在Apollo项目的构建过程中添加这样的配置。

如果您需要更多的帮助,或者有其他的问题,欢迎随时向我提问。

Sources


This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

nobodyiam commented 9 months ago

js 文件是有版本号的

image

不过菜单列表确实没有,是依靠缓存过期的,默认是 24 小时

image

luger1990 commented 9 months ago

js 文件是有版本号的

image

不过菜单列表确实没有,是依靠缓存过期的,默认是 24 小时

image

明白了。多谢!