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

Caching: output hashed assets to dedicated folders #3156

Closed
slorber opened this issue Jul 29, 2020 · 4 comments
Closed

Caching: output hashed assets to dedicated folders #3156

slorber opened this issue Jul 29, 2020 · 4 comments
Labels
difficulty: intermediate Issues that are medium difficulty level, e.g. moderate refactoring with a clear test plan. feature This is not a bug or issue with Docusausus, per se. It is a feature request for the future. good first issue If you are just getting started with Docusaurus, this issue should be a good place to begin. mlh Major League Hacking Fellowship

Comments

@slorber
Copy link
Collaborator

slorber commented Jul 29, 2020

🚀 Feature

Currently, the build output looks like:

  • ./build/index.html
  • ./build/docs/myDoc/index.html
  • ./build/someJs.hash.js
  • ./build/someCSS.hash.CSS
  • ./build/someImage.hash.png
  • ./build/someOtherImage.jpeg

Having this flat structure with all file types (hashed or not) melted at the root makes the caching story more complex.

Hashed assets are safe to cache very aggressively, and we should rather move them to a subfolder so that it's easy to enable caching.

For example, aggressive caching can be set by dropping a ./build/_headers config file:

/hashed/*
  cache-control: immutable

It is possible to output the webpack JS files in subfolders:

      filename: isProd ? 'hashed/js/[name].[contenthash:8].js' : '[name].js',
      chunkFilename: isProd
        ? 'hashed/js/[name].[contenthash:8].js'
        : '[name].js',

It should also be possible to achieve with other assets (css, images...).

The files of the /static folder will not be processed by webpack, and not be hashed so they can stay at the root without aggressive caching.

@slorber slorber added feature This is not a bug or issue with Docusausus, per se. It is a feature request for the future. status: needs triage This issue has not been triaged by maintainers difficulty: intermediate Issues that are medium difficulty level, e.g. moderate refactoring with a clear test plan. good first issue If you are just getting started with Docusaurus, this issue should be a good place to begin. mlh Major League Hacking Fellowship v2 and removed status: needs triage This issue has not been triaged by maintainers labels Jul 29, 2020
@creatorpiyush
Copy link

hi, can I work on this issue?

@slorber
Copy link
Collaborator Author

slorber commented Jul 30, 2020

yes thanks

@slorber
Copy link
Collaborator Author

slorber commented Jul 31, 2020

@creatorpiyush I just merged this: #3180
With /assets/images, /assets/media, /assets/files:

I guess you can do the same and tell webpack to output in /assets/js, /assets/css...

@slorber
Copy link
Collaborator Author

slorber commented Jan 5, 2021

closed by #3998

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: intermediate Issues that are medium difficulty level, e.g. moderate refactoring with a clear test plan. feature This is not a bug or issue with Docusausus, per se. It is a feature request for the future. good first issue If you are just getting started with Docusaurus, this issue should be a good place to begin. mlh Major League Hacking Fellowship
Projects
None yet
Development

No branches or pull requests

2 participants