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

Improve long term caching #1062

Open
1 task
ChristopherChudzicki opened this issue Jan 27, 2023 · 2 comments
Open
1 task

Improve long term caching #1062

ChristopherChudzicki opened this issue Jan 27, 2023 · 2 comments

Comments

@ChristopherChudzicki
Copy link
Contributor

ChristopherChudzicki commented Jan 27, 2023

Users should not need to re-download assets that they have already downloaded if the assets have not changed.

Our JS and CSS bundles are currently built with webpack's [fullhash] hashing. This hash changes if any aspect of the build has changed. For example:

  • if you change a CSS file, in www theme, all hashes change for all themes
  • if you add a comment to a webpack file, all hashes change even though no content has changed.
  • As part of only load Video and Image Gallery JS when needed #648, we probably want to bundle VideoJS and nanogallery2 separately. The hash of that chunk should unless the versions are bumped.

We probably want to be using [contenthash], not fullhash.

Acceptance Criteria:

  • Webpack hashes should not change unless the chunk's content has changed.
@ChristopherChudzicki
Copy link
Contributor Author

Part of our mass publish script is to purge the CDN cache https://github.com/mitodl/ocw-studio/blob/master/content_sync/pipelines/definitions/concourse/mass-build-sites.yml#L51 If we made the above webpack improvement, would we need to change the CDN purging also in order for users to benefit?

@ChristopherChudzicki
Copy link
Contributor Author

I think the answer to

If we made the above webpack improvement, would we need to change the CDN purging also in order for users to benefit?
is: Yes, cache purge means users would not benefit, and we should

  1. Make the change mentioned above
  2. Also set Cache-control: Max-age to something very large. Currently users do not load our resources from memory cache without first checking with the servers, but since we hash the js/css files, there's no need to check the servers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant