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

fix: disable caching of assets for the development server #1307

Merged
merged 1 commit into from
Nov 11, 2020

Conversation

satya164
Copy link
Member

@satya164 satya164 commented Nov 5, 2020

Summary:

It looks like the built assets get cached sometimes causing issues such as facebook/react-native#28844
This might happen if the HTML file got cached, but there's a new version available with different links.

It's better to disable the caching altogether since the development server is run locally and caching files causes more problems than it helps.
Normally it's possible by developers to disable caching when devtools is open, but it's not reasonable to expect everyone to do it.

The commit changes 2 things:

  • Set relevant headers to prevent caching of assets using the 'nocache' middleware
  • When building files with parcel, make sure that the name of the built files don't change

Fixes #1081

Test Plan:

I have tested this in a fresh React Native project following the instructions in CONTRIBUTING.md and observed that the debugger works as expected.

cc @brentvatne

It looks like the built assets get cached sometimes causing issues such as facebook/react-native#28844
This might happen if the HTML file got cached, but there's a new version available with different links.

It's better to disable the caching altogether since the development server is run locally and caching files causes more problems than it helps.
Normally it's possible by developers to disable caching when devtools is open, but it's not reasonable to expect everyone to do it.

The commit changes 2 things:

- Set relevant headers to prevent caching of assets using the 'nocache' middleware
- When building files with parcel, make sure that the name of the built files don't change

I have tested this in a fresh React Native project following the instructions in CONTRIBUTING.md and observed that the debugger works as expected.
Copy link
Member

@thymikee thymikee left a comment

Choose a reason for hiding this comment

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

Great stuff! Can we make sure that disabling server cache doesn't impact performance a lot?

@brentvatne
Copy link
Contributor

looks great! can we get this backported and published to the cli version used by react-native 63 as well?

@thymikee thymikee merged commit f94673c into master Nov 11, 2020
@thymikee thymikee deleted the @satya164/disable-cache branch November 11, 2020 15:45
grabbou pushed a commit that referenced this pull request Nov 19, 2020
It looks like the built assets get cached sometimes causing issues such as facebook/react-native#28844
This might happen if the HTML file got cached, but there's a new version available with different links.

It's better to disable the caching altogether since the development server is run locally and caching files causes more problems than it helps.
Normally it's possible by developers to disable caching when devtools is open, but it's not reasonable to expect everyone to do it.

The commit changes 2 things:

- Set relevant headers to prevent caching of assets using the 'nocache' middleware
- When building files with parcel, make sure that the name of the built files don't change

I have tested this in a fresh React Native project following the instructions in CONTRIBUTING.md and observed that the debugger works as expected.
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

Successfully merging this pull request may close these issues.

Unable to resolve module ./debugger-ui/ui.cc464243.js from ``
3 participants