Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

feat(nuxt): Feature/add initialCache option in runtimeConfig.app #7807

Closed

Conversation

TheDutchCoder
Copy link
Contributor

Note: mainly looking for feedback on:

  1. Is this a welcome change?
  2. Did I do it right?
  3. Did I update the docs appropriately?
  4. Do I need to add more docs (probably)?

I don't want to waste your time, so feel free to close this if it's an unwanted addition!

🔗 Linked issue

Currently not an open issue, but a started idea/discussion. I can make a related issue, but first wanted to run this by you guys.

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

Currently, all data is fetched with { initialCache: true } as the default setting. This setting can't be changed on a configuration level, which means people have to set { initialCache: false } on every single query if they don't want caching by default, which is cumbersome.

This setting will allow people to specify a default caching strategy on a config level:

export default defineNuxtConfig({
  runtimeConfig: {
    app: {
      initialCache: false
    }
  }
})

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@codesandbox
Copy link

codesandbox bot commented Sep 24, 2022

CodeSandbox logoCodeSandbox logo  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

@netlify
Copy link

netlify bot commented Sep 24, 2022

Deploy Preview for nuxt3-docs canceled.

Name Link
🔨 Latest commit c9a22bb
🔍 Latest deploy log https://app.netlify.com/sites/nuxt3-docs/deploys/632f639c1fa5cd0008fd39d5

@TheDutchCoder
Copy link
Contributor Author

This obviously doesn't work yet, I'm probably approaching the config part wrong.
Will try to make it work so the tests pass, and add a new test case if I can!

@TheDutchCoder
Copy link
Contributor Author

TheDutchCoder commented Sep 24, 2022

Ok, it works properly now, but I'm lost with the tests. Not really sure how they work under the hood.

@pi0
Copy link
Member

pi0 commented Nov 10, 2022

Thanks for PR. Planning to drop initialCache and disable it by default (#8885).

BTW supporting global options that change behavior might be tricky. If a Nuxt module or library depends on default behavior, it can be broken easily.

@pi0 pi0 closed this Nov 10, 2022
@danielroe danielroe added the 3.x label Jan 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants