【问题标题】:Nuxt generate not clear the cache for new updatesNuxt 生成不清除缓存以获取新更新
【发布时间】:2021-02-23 10:19:29
【问题描述】:

版本

  • nuxt:2.14.6
  • 节点:v15.9.0

预期什么?

将每个更新文件上传到 dist 文件夹内的共享主机后。浏览器将加载新版本

实际发生了什么?

正在使用共享主机来托管项目。我正在使用nuxt generate 命令编译它。编译并上传每次更新后,不需要重新加载页面。假设我的域名像这样http://example.com,如果我在浏览器中输入它会加载旧版本。但是,如果我输入 http://example.com/login 它会加载新版本,但如果我关闭选项卡并再次加载 http://example.com 它会加载旧版本,则不会更新浏览器缓存。如果我用旧版本加载http://example.com 并重新加载页面,它会更新浏览器缓存。另外我正在使用 nuxtjs pwa 是否有机会使用 pwa 发生此问题?

【问题讨论】:

    标签: vue.js nuxtjs


    【解决方案1】:

    您应该为您的应用程序使用流程管理器。 PM2可以帮到你。

    npmyarn 安装pm2

    • 向其中添加应用程序和您的包文件,如下所示:
      "dev": "nuxt --host domainname --port portnamber",
      
      "build": "nuxt build",
      
      "start": "nuxt start",
      
      "generate": "nuxt generate",
      
      "deploy": "pm2 start npm --name nameofapp -- start"
      
      
    • 它需要.htaccess 配置:
      RewriteEngine On
      
      RewriteCond %{SERVER_PORT} 443
      
      RewriteRule ^index.php(.*) domainname:portnumber/$1 [P,L]
      
      RewriteRule (.*) domainname:portnumber/$1 [P,L]
      
    • 运行:
      npm run deploy 
      
    • 那么你应该知道pm2 脚本:
      pm2 start appname
      

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-03-10
      • 2015-11-04
      • 1970-01-01
      • 2013-12-16
      • 2011-08-31
      • 2019-08-02
      • 2012-09-21
      • 2011-03-14
      相关资源
      最近更新 更多