Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Use unversioned frontend asset paths #25994

Merged
merged 6 commits into from
Jun 29, 2021

Conversation

billyvg
Copy link
Member

@billyvg billyvg commented May 11, 2021

This builds on top of #25744 where we refactored our JS entry points to be lightweight and to use dynamic imports (via webpack) to load the rest of the JS application.

This PR will now remove the need for the backend to be updated in order to release a new frontend. This will allow us to have frontend-only deploys which should complete much faster than a full deploy. We accomplish this by removing the webpack manifest plugin introduced in #25234, where we previously were versioning by a release string in the asset path. These unversioned asset files will be served using a Cache-Control: no-cache header which tells clients that they need to check against the origin server to see if the asset has changed, if it has not, they can use their cached copy. These unversioned files will end up changing quite frequently with every release, but they should be relatively small. They contain the webpack runtime that allows us to load the rest of our application bundles, which are versioned by a hash of their contents. These versioned chunks will have a long-term max-age for caching as the hash in the file name will serve to cache bust.

@billyvg billyvg force-pushed the build/deploy/frontend-only-deploys branch from 0c995d0 to a638e7c Compare May 14, 2021 22:24
@billyvg billyvg force-pushed the build/deploy/frontend-only-deploys branch from a638e7c to 8863267 Compare May 18, 2021 18:07
@billyvg billyvg force-pushed the build/deploy/frontend-only-deploys branch from 8863267 to cef276d Compare May 20, 2021 00:39
@billyvg billyvg force-pushed the build/deploy/frontend-only-deploys branch from cef276d to d5707c7 Compare June 2, 2021 01:13
@billyvg billyvg force-pushed the build/deploy/frontend-only-deploys branch from d5707c7 to 7219708 Compare June 7, 2021 23:50
@billyvg billyvg changed the base branch from master to build/deploy/frontend-only-deploys-remove-webpack-manifest June 7, 2021 23:50
@billyvg billyvg changed the base branch from build/deploy/frontend-only-deploys-remove-webpack-manifest to build/webpack/refactor-to-load-vendor-from-app-entrypoint-try-2 June 8, 2021 00:11
@billyvg billyvg force-pushed the build/deploy/frontend-only-deploys branch from 7219708 to 0acf716 Compare June 8, 2021 00:15
@billyvg billyvg force-pushed the build/webpack/refactor-to-load-vendor-from-app-entrypoint-try-2 branch 2 times, most recently from 5b54806 to 294b927 Compare June 16, 2021 23:22
@billyvg billyvg force-pushed the build/webpack/refactor-to-load-vendor-from-app-entrypoint-try-2 branch 2 times, most recently from ee4f9d9 to 7bafdaa Compare June 23, 2021 21:30
Base automatically changed from build/webpack/refactor-to-load-vendor-from-app-entrypoint-try-2 to master June 23, 2021 21:56
@billyvg billyvg force-pushed the build/deploy/frontend-only-deploys branch from 264974c to 8419b55 Compare June 23, 2021 22:02
@billyvg billyvg changed the title feat: Use unversioned frontend asset names feat: Use unversioned frontend asset paths Jun 28, 2021
@@ -130,7 +130,6 @@
"u2f-api": "1.0.10",
"webpack": "5.40.0",
"webpack-cli": "4.7.2",
"webpack-manifest-plugin": "^3.1.1",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great

@billyvg
Copy link
Member Author

billyvg commented Jun 28, 2021

Tested this for on-prem using 2 images (one normal and one with an update to the background color as a test) -- the frontend assets loaded as expected

Copy link
Member

@evanpurkhiser evanpurkhiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@billyvg billyvg force-pushed the build/deploy/frontend-only-deploys branch from e270bae to 9bd822d Compare June 29, 2021 03:37
@billyvg billyvg changed the base branch from master to build/webpack/organize-webpack-outputs June 29, 2021 03:37
Base automatically changed from build/webpack/organize-webpack-outputs to master June 29, 2021 16:55
billyvg added 6 commits June 29, 2021 09:56
This inverts the relationship between inline scripts in templates and our main js app bundle. Previously, the templates assume that certain bundles are loaded synchronously. We also expose certain components in the app bundle via globals (`SentryApp`). This would no longer work if (when) we make our bundles loaded async.

Instead of exposing components through globals, allow templates to queue up predefined tasks (there are some future optimizations here as I do not believe these other django templates that extend from `layout.html` need the main app bundle). After we render the SPA to the DOM, we will iterate through `__onSentryInit` and perform the necessary initializations.
… and make all entries async (#25566)" (#25681)"

This reverts commit 127fb2e.
@billyvg billyvg force-pushed the build/deploy/frontend-only-deploys branch from 9bd822d to 12799d3 Compare June 29, 2021 16:56
@billyvg billyvg merged commit 3d33cb5 into master Jun 29, 2021
@billyvg billyvg deleted the build/deploy/frontend-only-deploys branch June 29, 2021 19:28
billyvg added a commit that referenced this pull request Jun 29, 2021
billyvg added a commit that referenced this pull request Jun 29, 2021
billyvg added a commit that referenced this pull request Jul 1, 2021
This reverts commit 3228492.

This builds on top of #25744 where we refactored our JS entry points to be lightweight and to use dynamic imports (via webpack) to load the rest of the JS application.

This PR will now remove the need for the backend to be updated in order to release a new frontend. This will allow us to have frontend-only deploys which should complete much faster than a full deploy. We accomplish this by removing the webpack manifest plugin introduced in #25234, where we previously were versioning by a release string in the asset path. These unversioned asset files will be served using a [`Cache-Control: no-cache`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#cacheability) header which tells clients that they need to check against the origin server to see if the asset has changed, if it has not, they can use their cached copy. These unversioned files will end up changing quite frequently with every release, but they should be relatively small. They contain the webpack runtime that allows us to load the rest of our application bundles, which are versioned by a hash of their contents. These versioned chunks will have a long-term `max-age` for caching as the hash in the file name will serve to cache bust.

Note: this was reverted in
#25994 as it broke production
due to our CDN having cached an old asset due to a cache
misconfiguration during development. This was also not caught in staging
because we needed to change the asset paths for staging deploys to avoid
clobbering production assets.
billyvg added a commit that referenced this pull request Jul 1, 2021
This reverts commit 3228492.

This builds on top of #25744 where we refactored our JS entry points to be lightweight and to use dynamic imports (via webpack) to load the rest of the JS application.

This PR will now remove the need for the backend to be updated in order to release a new frontend. This will allow us to have frontend-only deploys which should complete much faster than a full deploy. We accomplish this by removing the webpack manifest plugin introduced in #25234, where we previously were versioning by a release string in the asset path. These unversioned asset files will be served using a [`Cache-Control: no-cache`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#cacheability) header which tells clients that they need to check against the origin server to see if the asset has changed, if it has not, they can use their cached copy. These unversioned files will end up changing quite frequently with every release, but they should be relatively small. They contain the webpack runtime that allows us to load the rest of our application bundles, which are versioned by a hash of their contents. These versioned chunks will have a long-term `max-age` for caching as the hash in the file name will serve to cache bust.

Note: this was reverted in #25994 as it broke production due to our CDN having cached an old asset due to a cache misconfiguration during development. This was also not caught in staging because we needed to change the asset paths for staging deploys to avoid clobbering production assets.
billyvg added a commit that referenced this pull request Jul 7, 2021
This reverts commit 388edc8.

This builds on top of #25744 where we refactored our JS entry points to be lightweight and to use dynamic imports (via webpack) to load the rest of the JS application.

This PR will now remove the need for the backend to be updated in order to release a new frontend. This will allow us to have frontend-only deploys which should complete much faster than a full deploy. We accomplish this by removing the webpack manifest plugin introduced in #25234, where we previously were versioning b
y a release string in the asset path. These unversioned asset files will be served using a
[`Cache-Control: no-cache`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache
-Control#cacheability) header which tells clients that they need to check against the origi
n server to see if the asset has changed, if it has not, they can use their cached copy. Th
ese unversioned files will end up changing quite frequently with every release, but they sh
ould be relatively small. They contain the webpack runtime that allows us to load the rest
of our application bundles, which are versioned by a hash of their contents. These versione
d chunks will have a long-term `max-age` for caching as the hash in the file name will serv
e to cache bust.

Note: this was reverted in #25994 as it broke p
roduction due to our CDN having cached an old asset due to a cache misconfiguration during
development. This was also not caught in staging because we needed to change the asset path
s for staging deploys to avoid clobbering production assets, and the staging path was not p
reviously cached.


Requires #26987
@github-actions github-actions bot locked and limited conversation to collaborators Jul 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants