Reputation: 26182
I deploy my web application server code to the cloud platform. While the procedure the deploy tool takes all files (from local file system or git repo), uploads it to the cloud and restarts the app.
Every time my front-app assets (images, css, js) change I need to redeploy the whole app (and restart it). There is not build in file API to upload only some files for the application.
My build process of front app prepares all the assets: images, css, js and index.html file that contains references to the assets. Every build assets have different md5 names (if changed) to insure caching.
After front build is completed it deploy the whole app. User request the certain address and server responds with new app's index.html.
What I want is to avoid deploy of server app, when only the front app is changed.
I can upload new files to CDN, but the client first will connect to the server and it needs to know which assets it should load (actually it needs correct index.html in response).
The problem is about updating web application front assets and references on server without touching other parts of running server app.
How this problem can be solved?
What I though of:
Every time client request the server for the app, it builds correct index.html using template and database data.
The alternative option without using database, every time client request the server, server first requests some CDN (or shared location) with correct index.html, and responds to the client.
Which way is more correct to go with, and what are best practices for that problem?
Upvotes: 1
Views: 1490
Reputation: 300
One way around this problem is proper separation of business logic and your views. Restructuring your application along the lines stated below would benefit you in the long run.
1.Build an API out of your current business logic.
2.Convert your views into a full client side application with a client side technology like angular, react, backbone, etc.
Your client can be pushed to a CDN (or hosted separately) easily and only maintains reference to your server API.
This way your server app doesn't know anything about your views/client apart from handling API calls.
Upvotes: 1