Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
luger1990 opened this issue Dec 21, 2023 · 3 comments

Comments

@luger1990
Copy link

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

Copy link

dosubot bot commented Dec 21, 2023

🤖

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
Copy link
Member

js 文件是有版本号的

image

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

image

@luger1990
Copy link
Author

js 文件是有版本号的

image

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

image

明白了。多谢!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants