-
Notifications
You must be signed in to change notification settings - Fork 19
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
Route caching limitations - nuxtApp.payload.path #39
Comments
Currently trying to setup a reproduction. As you stated correctly, using any query parameter as part of the cache key is dangerous. And if I got that right, the bug happens when the first request has a query parameter and subsequent requests (served from cache), either with or without a query parameter will add the query param from the cached route in the browser. I'm not sure how this could be fixed. It's indeed a bug, but kind of also an "expected bug" 😄 I think the proper solution would be to enforce query parameters before rendering the page. So in our example, if a request is made to |
The current workaround was to add a server-side plugin
But it's better to figure out why this is expected behavior in nitro: |
But won't this lead to hydration issues? The cached route that is being served expects a certain query parameter value, say Something that crossed my mind just now is to offer a new method on the route cache helper, something like <template>
<div id="query-id">{{ id }}</div>
</template>
<script lang="ts" setup>
import { useRouteCache, useRoute, computed } from '#imports'
const route = useRoute()
const id = computed(() => route.query.id)
useRouteCache((helper) => helper.setCacheable().setQuery('id'))
</script> This would give the route cache a hint about which query parameters (and possibly even values) would be allowed. It could then be used to build the appropriate cache key. If |
nuxt/nuxt#26071
The text was updated successfully, but these errors were encountered: