8

Versions

  • nuxt: 2.14.6
  • node: v15.9.0

What is Expected?

After upload every updates file to shared hosting inside dist folder. browser will load new version

What is actually happening?

'm using shared hosting to host the project. I'm using nuxt generate command compile it. After compile and upload every update it not effect need to reload the page. Assume my domain name like this http://example.com if i enter this in browser it load old version. But if I enter http://example.com/login it's load new version but not update the browser cache if I close tab and again load http://example.com its load old version. If I load http://example.com with old version and reload page it update the browser cache . Also I'm using nuxtjs pwa is there any chance to happen this issue using pwa?

Tharindu Prabodhana
  • 181
  • 1
  • 4
  • 16

1 Answers1

0

You should use process manager for your application. PM2 can help you.

Install pm2 from npm or yarn.

  • Add application to it and your package file like this:
    "dev": "nuxt --host domainname --port portnamber",
    
    "build": "nuxt build",
    
    "start": "nuxt start",
    
    "generate": "nuxt generate",
    
    "deploy": "pm2 start npm --name nameofapp -- start"
    
    
  • It require .htaccess config :
    RewriteEngine On
    
    RewriteCond %{SERVER_PORT} 443
    
    RewriteRule ^index.php(.*) domainname:portnumber/$1 [P,L]
    
    RewriteRule (.*) domainname:portnumber/$1 [P,L]
    
  • run:
    npm run deploy 
    
  • then you should know pm2 script:
    pm2 start appname
    
cursorrux
  • 1,382
  • 4
  • 9
  • 20
  • 1
    `nuxt generate` will generate static files which runs on ftp not a node server! This problem can be solved using `workbox` [link](https://stackoverflow.com/questions/70496047/nuxt-pwa-update-version) – Pouya M May 30 '22 at 15:03