1

I have recently put an admin-on-rest app into production and it works great. However, when I update the app, the updated files within my project src directory are cached. For example I made a change to the restClient.js file, but this only gets loaded after users do a CTRL+F5 in the app.

What is the recommended way to handle this? Can I somehow add a cachebust to the files? Or should I simply set expires in the index.html file head section?

Ps. this questions is maybe more related to React apps in general then admin-on-rest..

Developer Guy
  • 2,318
  • 6
  • 19
  • 37
Marcel
  • 105
  • 6
  • 1
    How are you running your project ? It looks like you're not using webpack or haven't configured it correctly – Gildas Garcia Apr 19 '18 at 16:47
  • I have had someone external install it for me on a VPS. I don't think webpack is used. I beleive Nginx and Node JS are used. I will contact the guy who installed it to see if we can use webpack because it looks like that's what I need. – Marcel Apr 20 '18 at 08:33
  • I may have misread your question: do you have this problem in development mode or with your production files ? – Gildas Garcia Apr 23 '18 at 19:21
  • Hi, it is with the production files. If I inspect the files with webdeveloper tool in Chrome I can see the name has no cachebust or something like that. I just see /static/js/restClient.js and I think it is cached by the browser? In development mode everything is working fine (on my Windows machine with Node.js), if I change a file it recompiles, refreshes the browser and I see the changes immediately – Marcel Apr 24 '18 at 11:43
  • So I did misunderstand your question... This is not a problem about Admin-On-Rest nor React. There's probably something to configure on the server side. Do you know how your files are served ? – Gildas Garcia Apr 24 '18 at 12:06
  • I had someone install it on a server for me. He gave me these instructions to deploy a new version: (1) yarn build (2) pm2 start portal.sh (3) service nginx restart. The portal.sh does #!/bin/bash serve -s build. My package.json contains a build instruction with value: PORT=5001 react-scripts build. It does not say anything to me, but maybe you can make up something from this? :) – Marcel Apr 24 '18 at 12:21
  • Would you mind pasting the script part of the package.json ? – Gildas Garcia Apr 25 '18 at 05:40
  • Appreciate your help! Here's my package.json: { "name": "portal", "version": "1.1", "private": true, "dependencies": { "admin-on-rest": "^1.4.0", "react": "^16.3.0", "react-dom": "^16.3.0", "react-scripts": "1.1.1" }, "scripts": { "start": "react-scripts start", "build": "PORT=5001 react-scripts build", "test": "react-scripts test --env=jsdom", "eject": "react-scripts eject" } – Marcel Apr 25 '18 at 08:29

0 Answers0