Add CDN asset hosting option#1954
Open
iturgeon wants to merge 3 commits intoucfopen:dev/31-taconitefrom
Open
Conversation
c9608f3 to
d18c254
Compare
Member
Author
|
UPDATE: The latest commit will allow module images to be loaded through a CDN as well. This would require the CDN to be able to pass requests to |
Supports setting an env var for CDN_ASSET_HOST. Doing so will prepend the asset urls that are built in asset_resolver with a cdn. For this to work, you need to set CDN_ASSET_HOST=https://cdn.com Then upload everything from packages/app/obojobo-express/server/public to the cdn after running yarn build.
Now, setting CDN_ASSET_HOST will now prepend module image urls to the configured CDN. This required updates to some of the repository changes to pass a server variable to the universal react pages so they can render correctly on SSR and CSR environments.
8fdf35f to
0fefa40
Compare
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We do this to keep our backlog under control, but we thank you for your contributions. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Using a CDN for the compiled assets will free up the node server to focus on the tasks it's really needed for. Doing so will speed up the server, reduce server hosting costs, and speed up end user's load times.
Since this added env vars, I figured I'd add a list on configuration env vars to the readme.
Adds:
To use a CDN, set CDN_ASSET_HOST=https://cdn.com
Then upload everything from packages/app/obojobo-express/server/public to the CDN after running
yarn buildfor the exact version of the site you deploy.To add further detail:
yarn builduses webpack, and the assets are named with a name that includes a hash based on the content of the file. Webpack creates a manifest file that is used to look up this hash name - if obojobo is looking for 'fancy-file.js' the manifest is used to look up the built file's namefancy-file-<hash>.js. Because of this - the files on the CDN need to be updated when the js/css/images are updated because the updated build for obojobo will be looking for a new file by name.This means the deploy process would need to include running yarn build then uploading the public folder to the CDN on every deploy of a new version of the application.