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
Serve correctly hashed static files with the Cache-Control header #10390
Serve correctly hashed static files with the Cache-Control header #10390
Conversation
It looks like the build is failing - we rebased onto the (as of writing this message) latest commit on |
aeb6289
to
03cbea3
Compare
03cbea3
to
9d25aa1
Compare
So when a user DOES make a change to the file, will it still show the new version? |
@ndelangen Yes, when changes are made (e.g. edits, creation) the new changes are correctly pulled in with the expected |
However, this doesn't work for files without the hash in their name (i.e., files in the |
Is there a way to get this behaviour also for files covered by |
Issue: #8278
By @eashwar and @christopherhafke.
What we did
After reproducing the behavior described in #8278, we added the
Cache-Control
header to both the static files in the user-specifiedstaticDir
as well as any files served from/static/media
(i.e., files loaded and hashed byfile-loader
).How to test
To test this change, one can write any story that uses some static file (like an image) located in the
public
orsrc
directories of a project. An example of a story that we wrote forexamples/cra-react15
:Run
yarn storybook
, go to the story (with browser devtools open). The response header for the image file should have the headerCache-Control
. Reload the page, and the network request made for the image (in this example,logo.svg
), should say something along the lines of200 (from memory/disk cache)
in the response header (as opposed to304 not modified
).Is this testable with Jest or Chromatic screenshots?
We're unsure about how we could test something like this with Jest, or if that needs to be done at all -
build-dev.js
anddev-server.js
don't seem to have tests written for them.Does this need a new example in the kitchen sink apps?
This is unlikely, as the PR does not add any new functionality (instead improves existing functionality).
Does this need an update to the documentation?
No.